forked from AllenDowney/ThinkJavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPetTester.java
More file actions
26 lines (20 loc) · 719 Bytes
/
PetTester.java
File metadata and controls
26 lines (20 loc) · 719 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
public class PetTester
{
public static void main(String[] args)
{
Pet pet1 = new Pet("Rocky" , 4, "dog");
System.out.println(pet1.getName() + " age of " + pet1.getAge() + " " + pet1.getAnimal());
Pet pet2 = new Pet("Benji" , 2, "dog");
pet2.setName("BingBong");
pet2.incrementAge();
System.out.println(pet2.getName() + " age of " + pet2.getAge() + " " + pet2.getAnimal());
Pet[] pets = new Pet[3];
pets[0] = new Pet("Inky", 2, "Smurf");
pets[1] = new Pet("Blinky", 5, "Aardvark");
pets[2] = new Pet("Clyde", 6, "Narwhal");
for( Pet pet:pets)
{
System.out.println(pet.getName());
}
}
}