11-07feb27casting - C S100J 1. 2. 3. 27 F eb ru ary 2 006 C...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CS100J 27 February 2006 Casting About 1. Casting between classes 2. Apparent and real classes. 3. Operator instanceof Procrastination Leave nothing for to-morrow that can be done to-day. Lincoln How does a project get a year behind schedule? One day at a time. Fred Brooks I don't wait for moods. You accomplish nothing if you do that. Your mind must know it has got to get down to work. Pearl S. Buck When I start a new project, I procrastinate immediately so that I have more time to catch up. Gries 4. The class hierarchy 5. function equals Study Secs 4.2 and 4.3 in text Buy a poster with the procrastinator’s creed here: http://www.art.com/asp/sp-asp/_/pd--10001845/Procrastinators_Creed.htm After today, you have learned ALL the basics of classes, and done extremely well. Be proud of yourselves. 2 Class Animal public class Animal { private String name; // name of the animal private int age; // age of animal /** Constructor: an Animal with name n, age a */ public Animal(String n, int a) { name= n; age= a; } /** = "this Animal is older than h" */ public boolean isOlder(Animal h) { return this.age > h.age; } /** = the noise that the animal makes -- "" in class Animal */ public String getNoise () { return ""; } /** = the name of this Animal */ public String getName() { return name; } /** = a description of this Animal */ public String toString() { return "Animal " + name + ", age " + age; } } We put each method on one line to save space on the slide. Don’t do it in your program.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/03/2012 for the course CS 100J taught by Professor Davidgries during the Spring '07 term at Cornell University (Engineering School).

Page1 / 2

11-07feb27casting - C S100J 1. 2. 3. 27 F eb ru ary 2 006 C...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online