forked from mpmenne/launchcode-java-class
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCat.java
More file actions
31 lines (26 loc) · 646 Bytes
/
Copy pathCat.java
File metadata and controls
31 lines (26 loc) · 646 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* Created by dshook on 4/30/15.
*/
public class Cat extends Animal {
private String meow;
public Cat(String food, String meow) {
super("Cat", food);
this.meow = meow;
}
public void meow() {
System.out.println(this.meow);
}
public void eat() {
System.out.println("Cat is eating");
}
public static void main(String[] args) {
Animal[] zoo = new Animal[2];
Animal a = new Cat("fish", "ROWR");
Animal d = new Dog("woof");
zoo[0] = a;
zoo[1] = d;
for(int i = 0; i < zoo.length; i++) {
zoo[i].eat();
}
}
}