Download slides - Angus Forbes

Document related concepts
no text concepts found
Transcript
CS 5JA Introduction to Java
Inheritance
But there is enough basic “functionality” in our prototype to make it useful to define
a kind of basic bird which will contain most of the elements for most of the
birds...
So we’ll define a base class, which is the superclass for all the other birds. It won’t
extend from anything else
public class Bird
{
boolean migrates = false;
boolean canFly = true;
int colorful = false;
String favoriteFood = “worms”;
String typeOfBird;
public Bird(String typeOfBird)
{
this.typeOfBird = typeOfBird;
}
}