-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHuman.java
More file actions
105 lines (83 loc) · 2.17 KB
/
Copy pathHuman.java
File metadata and controls
105 lines (83 loc) · 2.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package com.example.Human;
public class Human {
String name;
private int age;
private int height;
private int weight;
private int width;
private boolean hair;
public Human(String name, int age, int height,int weight, int width, boolean hair){
this.name = name;
this.age = age;
this.height = height;
this.weight = weight;
this.width = width;
this.hair = hair;
}
public String getName(){
return name;
}
public int getAge(){
return age;
}
public int getHeight(){
return height;
}
public int getWeight(){
return weight;
}
public int getWidth(){
return width;
}
public boolean getHair(){
return hair;
}
public void changeName(String newName){
name = newName;
}
public void setAge(int newAge){
age = newAge;
}
public void setHeight(int newHeight){
height = newHeight;
}
public void setWeight(int newWeight){
weight = newWeight;
}
public void setWidth(int newWidth){
width = newWidth;
}
public void setHair(boolean newHair){
hair = newHair;
}
public void eat(int food){
height += food / 100;
}
public void useHairGrowerSpray(){
hair = true;
}
public void getOlder(){
age += 1;
}
public void canVote(int year){
if (year % 4 == 0 && age >= 18){
System.out.println("Can vote");
}
else{
System.out.println("Cannot vote");
}
}
public String toString(){
System.out.println(name + " " + age + " " + height + " " + weight + " " + width + " " + hair);
return name + " " + age + " " + height + " " + weight + " " + width + " " + hair;
}
public static void main(String[]args){
Human g = new Human("Condy", 17, 5, 150, 60, false);
g.eat(1000);
g.useHairGrowerSpray();
g.getOlder();
g.canVote(2020);
g.changeName("Cooper");
g.toString();
}
}