CSE 142 Critters (IPL) behavior: Ant Bird Hippo Vulture

Slides:



Advertisements
Similar presentations
CS 112 Introduction to Programming Critters/Event-Driven Programming; Interface Yang (Richard) Yang Computer Science Department Yale University 308A Watson,
Advertisements

CS 112 Introduction to Programming
Copyright 2008 by Pearson Education Building Java Programs Chapter 9 Lecture 9-2: Static Data; More Inheritance reading:
Copyright 2008 by Pearson Education Building Java Programs Chapter 9 Critters; Subtype Polymorphism Reading: HW9 Handout, Chapter 9.2.
Copyright 2010 by Pearson Education 1 Assignment 11: Critters reading: HW11 assignment spec.
Selected Problems from Chapter o.
Copyright 2010 by Pearson Education 1 Assignment 11: Critters.
Copyright 2008 by Pearson Education Building Java Programs Chapter 9 Lecture 9-x: Critters reading: HW9 Spec.
Variables and Functions. Open your Encoder program Let’s begin by opening the “Labyrinth Auto Straight” code. Save this file as Labyrinth with variables.
Object-Oriented Programming. An object is anything that can be represented by data in a computer’s memory and manipulated by a computer program.
Copyright 2010 by Pearson Education Homework 9: Critters (cont.) reading: HW9 spec.
29-July-2002cse Inheritance © 2002 University of Washington1 Inheritance CSE 142, Summer 2002 Computer Programming 1
Copyright 2008 by Pearson Education Building Java Programs Chapter 9 Lecture 9-2: Interacting with the Superclass ( super ) reading:
1 CS1110 Stepwise refinement, more on classes 24 Sep 2009 Application of String processing and stepwise refinement. Miscellaneous points about classes.
Building Java Programs Chapter 8 Lecture 8-3: Object state; Homework 8 (Critters) reading:
CS2102: Lecture on Abstract Classes and Inheritance Kathi Fisler.
Copyright 2008 by Pearson Education Building Java Programs Chapter 9 Lecture 9-2: Interacting with the Superclass ( super ); Discussion of Homework 9:
Copyright 2010 by Pearson Education Building Java Programs Homework 8: Critters reading: Critters Assignment Spec.
Copyright 2010 by Pearson Education Homework 8: Critters reading: HW8 spec.
Copyright 2008 by Pearson Education Building Java Programs Chapter 9 Lecture 9-2: Interacting with the Superclass ( super ); Discussion of Homework 9:
Copyright 2010 by Pearson Education Homework 9: Critters (cont.) reading: HW9 spec.
Copyright 2009 by Pearson Education Building Java Programs Chapter 8: Classes Lecture 8-3: More Critters, static.
Copyright 2009 by Pearson Education Building Java Programs Chapter 9: Inheritance and Interfaces Lecture 9-1.
CS 112 Introduction to Programming Method Overriding; Object Hierarchy; Event-Driven Programming Yang (Richard) Yang Computer Science Department Yale University.
CS 112 Introduction to Programming Critters, Polymorphism Yang (Richard) Yang Computer Science Department Yale University 208A Watson, Phone:
Adapted from slides by Marty Stepp and Stuart Reges
Lecture 5:Interfaces and Abstract Classes
Sprites (Images) and Sounds
Chapter 5 – Making Music: An On-Screen Piano (Part 1 – Using Loops)
Adapted from slides by Marty Stepp and Stuart Reges
Building Java Programs
University of Central Florida COP 3330 Object Oriented Programming
Discussion 2: More to discuss
Measures of Academic Progress (MAP)
Weds, Nov. 26th Reading: Section Handout
Homework 8: Critters reading: HW8 spec.
The software crisis software engineering: The practice of developing, designing, documenting, testing large computer programs. Large-scale projects face.
Adapted from slides by Marty Stepp and Stuart Reges
Computing with C# and the .NET Framework
Building Java Programs
University of Central Florida COP 3330 Object Oriented Programming
Agenda About Quiz ChameleonCritter class CrabCritter class homework.
Can perform actions and provide communication
HW11 Assignment Specification
CS2102: Lecture on Abstract Classes and Inheritance
Lecture 8-3: Encapsulation, this
Critter exercise: Snake
Can perform actions and provide communication
Homework 8: Critters (cont.)
Adapted from slides by Marty Stepp and Stuart Reges
Building Java Programs
The software crisis software engineering: The practice of developing, designing, documenting, testing large computer programs. Large-scale projects face.
Building Java Programs
Can perform actions and provide communication
Working with Maps Understanding the Hemispheres
Building Java Programs
Building Java Programs
Building Java Programs
Chapter 14 Abstract Classes and Interfaces
CSE 142 Lecture Notes Inheritance, Interfaces, and Polymorphism
Homework 8: Critters (cont.)
Building Java Programs
Building Java Programs
Homework 9: Critters (cont.)
Building Java Programs
Chapter 9 9-3: Polymorphism reading: 9.3
East West Move to Table 2 N/S
Student Center A South: Inaccessible Element
Building Java Programs
Indentation & Comments
Presentation transcript:

CSE 142 Critters (IPL) behavior: Ant Bird Hippo Vulture Husky (creative) behavior: eat eating food fight animal fighting getColor color to display getMove movement toString letter to display

A Critter subclass public class name extends Critter { ... } public abstract class Critter { public boolean eat() public Attack fight(String opponent) // ROAR, POUNCE, SCRATCH public Color getColor() public Direction getMove() // NORTH, SOUTH, EAST, WEST, CENTER public String toString() }

How the simulator works "Go" → loop: move each animal (getMove) if they collide, fight if they find food, eat Simulator is in control! getMove is one move at a time (no loops) Keep state (fields) to remember future moves Next move? %

Development Strategy Do one species at a time in ABC order from easier to harder (Ant → Bird → ...) debug printlns Simulator helps you debug smaller width/height fewer animals "Tick" instead of "Go" "Debug" checkbox

FAQ Q: "CritterMain does not compile." A: You may not have downloaded it properly. Q: "How do I use a value passed to the constructor later?" A: Store such values as fields. Q: "I wrote getColor/toString/etc. but it isn't being called." A: Make sure the method headers exactly match.