
WORST EVER
By: a guest on
Jul 30th, 2012 | syntax:
None | size: 0.89 KB | hits: 22 | expires: Never
Write a program that has three classes
Animal
Cat
Horse
Create an inheritance structure between them and make sure that each class has appropriate attributes. Each class should have a toString method that prints out the type of animal and the top class should be abstract. The following class should work with your code.
class BreakStudentCode {
public static void main(String[] argv) {
Animal myAnimal;
myAnimal = new Cat();
exampleMethod(myAnimal);
}
public static void exampleMethod(Animal anAnimal) {
System.out.println(anAnimal);
}
}
Finally
1. Modify this code to ask for which animal the user has
2. Ask for the attributes appropriate to that animal. You will need to modify the classes and constructors
3. Print that animal plus its attributes back out using the exampleMethod.//You are not to modify this method