KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > animals > Dog


1 package animals;
2
3 public class Dog extends Wolf {
4
5     String JavaDoc owner;
6
7     public Dog(String JavaDoc _name, int _color) {
8         super(_name, _color);
9     }
10
11     public void attack(String JavaDoc catName) {
12         System.out.println("The dog " + name + " (owner is " + owner
13             + ") attacks the cat " + catName);
14     }
15 /*
16     public void attack(Cat cat) {
17         System.out.println("The dog " + name + " (owner is " + owner
18             + ") attacks the cat " + cat.name);
19         cat.enemy = this;
20     }
21 */

22 }
23
Popular Tags