Files
  • Main.java
  • Bird.class
  • Bird.java
  • Dog.class
  • Dog.java
  • Main.class
  • Pet.class
  • Pet.java
  • Snake.class
  • Snake.java
Main.java
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
public class Main
{
   //-----------------------------------------------------------------
   //  Instantiates a dog and a snake object and prints information
   //  about them.
   //-----------------------------------------------------------------
   public static void main (String[] args)
   {
      Dog fido = new Dog("Fido", 45);
      Snake sam = new Snake("Sam", 30);
      Bird john = new Bird("John", 19);
      System.out.println(fido);
      System.out.println(fido.getName() + " says " + fido.speak());
      System.out.println(fido.move() + " " + fido.getName() + " " + fido.move());
      System.out.println();
      System.out.println(sam);
      System.out.println(sam.getName() + " says " + sam.speak());
      System.out.println(sam.move() + " " + sam.getName() + " " + sam.move());
      System.out.println();
      System.out.println(john);
      System.out.println(john.getName() + " says " + john.speak());
      System.out.println(john.move() + " " + john.getName() + " " + john.move());
   }
}