Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DogTester {
- public static void main(String []args) {
- // Create instances of Dog class, create 2 Dog objects
- Dog firstDog = new Dog("Charlie", "Caramel/Black", "Miniature Schnauzer/Havanese", 7);
- Dog secondDog = new Dog("Murphy", "Brown", "Golden Retriever", -99);
- // Call Dog method, getName
- System.out.println("Name of Dog entered: " + firstDog.getName());
- // Call Dog method, toString
- System.out.println(firstDog.toString());
- System.out.println(secondDog.toString());
- // Because we declared secondDog's age to be less than 0, constructor shall set it to 1
- // instead.
- // Let's change age of firstDog from 7 to 2 using dog class method, setAge
- firstDog.setAge(2);
- // Call Dog method, toString, to see if age has changed.
- System.out.println(firstDog.toString());
- }
- }
Add Comment
Please, Sign In to add comment