generated from athenian-apcs/pet-inheritance-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dog.java
35 lines (29 loc) · 723 Bytes
/
Dog.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
26
27
28
29
30
31
32
33
34
35
public class Dog extends Pet {
// Instance variable(s)
private String breed;
// Constructors
public Dog(String name, int age, String breed){
super(name,age);
this.breed = breed;
}
public Dog(){
super("Max",5);
this.breed = "Labrador";
}
// makeNoise() method
public void makeNoise(){
System.out.println("Woof!");
}
// toString method
public String toString(){
return "Name: " + this.getName() + ", Age: " + this.getAge() + ", Breed: " + this.breed;
}
// Getter
public String getBreed(){
return this.breed;
}
// Setter
public void setBreed(String breed){
this.breed = breed;
}
}