-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainClass.java
48 lines (38 loc) · 1.22 KB
/
MainClass.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
36
37
38
39
40
41
42
43
44
45
46
47
48
class Animal {
private String animal_name;
private int animal_age;
private String animal_color;
Animal(String animal_name, int animal_age, String animal_color) {
this.animal_name = animal_name;
this.animal_age = animal_age;
this.animal_color = animal_color;
}
public void setAnimalName(String animal_name) {
this.animal_name = animal_name;
}
public String getAnimalName() {
return this.animal_name;
}
public void setAnimalAge(int animal_age) {
this.animal_age = animal_age;
}
public int getAnimalAge() {
return this.animal_age;
}
public void setAnimalColor(String animal_color) {
this.animal_color = animal_color;
}
public String getAnimalColor() {
return this.animal_color;
}
public void sayHello() {
System.out.println("Hello, My name is " + this.getAnimalName());
System.out.println("My age is " + this.getAnimalAge() + " and my color is " + this.getAnimalColor());
}
}
public class MainClass {
public static void main(String[] args) {
Animal tom = new Animal("Tom", 10, "Black");
tom.sayHello();
}
}