-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTree.java
More file actions
54 lines (41 loc) · 1.15 KB
/
Tree.java
File metadata and controls
54 lines (41 loc) · 1.15 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
43
44
45
46
47
48
49
50
51
52
53
54
package homework1;
public class Tree {
// Instance variables
private int idNumber;
private int age;
private String speciesName;
// Parameterized constructor
public Tree(int idNumber, int age, String speciesName) {
this.idNumber = idNumber;
this.age = age;
this.speciesName = speciesName;
}
// Use Of Getters
public int getIdNumber() {
return idNumber;
}
public int getAge() {
return age;
}
public String getSpeciesName() {
return speciesName;
}
// Usage of setter (If you would want to allow modification)
public void setIdNumber(int idNumber) {
this.idNumber = idNumber;
}
public void setAge(int age) {
this.age = age;
}
public void setSpeciesName(String speciesName) {
this.speciesName = speciesName;
}
// toString method to print
@Override
public String toString() {
return "Tree{" +
"idNumber=" + idNumber +
", age=" + age +
", speciesName='" + speciesName + '\'' +
'}';
}}