binibiningtinamoran

DogTester

May 27th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. public class DogTester {
  2.  
  3.     public static void main(String []args) {
  4.  
  5.         // Create instances of Dog class, create 2 Dog objects
  6.         Dog firstDog = new Dog("Charlie", "Caramel/Black", "Miniature Schnauzer/Havanese", 7);
  7.         Dog secondDog = new Dog("Murphy", "Brown", "Golden Retriever", -99);
  8.  
  9.  
  10.         // Call Dog method, getName
  11.         System.out.println("Name of Dog entered: " + firstDog.getName());
  12.  
  13.         // Call Dog method, toString
  14.         System.out.println(firstDog.toString());
  15.  
  16.         System.out.println(secondDog.toString());
  17.         // Because we declared secondDog's age to be less than 0, constructor shall set it to 1
  18.         // instead.
  19.  
  20.         // Let's change age of firstDog from 7 to 2 using dog class method, setAge
  21.         firstDog.setAge(2);
  22.  
  23.         // Call Dog method, toString, to see if age has changed.
  24.         System.out.println(firstDog.toString());
  25.  
  26.     }
  27. }
Add Comment
Please, Sign In to add comment