-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDog.java
More file actions
24 lines (22 loc) · 836 Bytes
/
Copy pathDog.java
File metadata and controls
24 lines (22 loc) · 836 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
public class Dog {
String breed;
boolean hasOwner;
int age;
public Dog(String dogBreed, boolean dogOwned, int dogYears) {
System.out.println("Constructor invoked!");
breed = dogBreed;
hasOwner = dogOwned;
age = dogYears;
}
public static void main(String[] args) {
System.out.println("Main method started");
Dog fido = new Dog("poodle", false, 4);
Dog nunzio = new Dog("shiba inu", true, 12);
boolean isFidoOlder = fido.age > nunzio.age;
int totalDogYears = nunzio.age + fido.age;
System.out.println("Two dogs created: a " + fido.breed + " and a " + nunzio.breed);
System.out.println("The statement that fido is an older dog is: " + isFidoOlder);
System.out.println("The total age of the dogs is: " + totalDogYears);
System.out.println("Main method finished");
}
}