-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHuman.java
More file actions
42 lines (34 loc) · 1.17 KB
/
Human.java
File metadata and controls
42 lines (34 loc) · 1.17 KB
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
36
37
38
39
40
41
42
public class Human extends Animal {
private String region;
private String name;
public Human(int birthYear, String region, String name) {
super(birthYear);
this.region = region;
this.name = name;
}
public String getRegion() {
return region;
}
public String getName() {
return name;
}
public void makeSound() {
System.out.println("My name is " + name);
}
public void dance() {
System.out.println("I am from " + region + ", my name is " + name + " and I am dancing.");
}
public static void main(String[] args) {
Human dave = new Human(2000, "Bronx", "Dave");
Human jamal = new Human(1992, "Oakland", "Jamal");
Dog cookie = new Dog(2015, "Cookie");
dave.dance();
dave.makeSound();
System.out.println(dave.getName() + " is " + dave.calculateAge() + " years old.");
jamal.dance();
jamal.makeSound();
System.out.println(jamal.getName() + " is " + jamal.calculateAge() + " years old.");
cookie.makeSound();
System.out.println(cookie.getName() + " is " + cookie.calculateAge() + " years old.");
}
}