-
Notifications
You must be signed in to change notification settings - Fork 0
/
Person.java
68 lines (59 loc) · 1.54 KB
/
Person.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package oop1;
public class Person {
private String name;
private int age;
private String id;
private double weight;
private double height;
public Person() {
}
public Person(String name, int age, String id) {
this.name = name;
this.age = age;
this.id = id;
}
public Person(String name, int age, String id, double weight, double height) {
this.name = name;
this.age = age;
this.id = id;
this.weight = weight;
this.height = height;
}
public int calculateIMC(){
double imcValue = weight / (height * height);
if (imcValue < 20.0)
return -1;
if (imcValue < 25.0)
return 0;
else
return 1;
}
public String imcLevel() {
switch (calculateIMC()){
case -1:
return "Abaixo do peso";
case 0:
return "Peso saudavel";
case 1:
return "Sobre peso";
default:
return null;
}
}
public boolean isOfAge() {
return age >= 18;
}
@Override
public String toString() {
return "Person{" +
"name='" + name + '\'' +
", age=" + age +
", id='" + id + '\'' +
", weight=" + weight +
", height=" + height +
", IMC=" + calculateIMC() +
", IMC nivel=" + imcLevel() +
", isOfAge=" + isOfAge() +
'}';
}
}