idzik icon

Junior-Java-Developer-Czlowiek

idzik | PRO | 11/23/16 02:22:35 PM UTC | 0 ⭐ | 359 👁️ | Never ⏰ | []
Java |

1.44 KB

|

None

|

0 👍

/

0 👎

 
public class Czlowiek implements Comparable<Czlowiek>{
private String name;
private String surname;
private int age;
private int height;
private int weight;
 
 
 
public String getName() {
    return name;
}
 
 
 
public void setName(String name) {
    this.name = name;
}
 
 
 
public String getSurname() {
    return surname;
}
 
 
 
public void setSurname(String surname) {
    this.surname = surname;
}
 
 
 
public int getAge() {
    return age;
}
 
 
 
public void setAge(int age) {
    if(age>0)
    this.age = age;
    else
        this.age=0;
}
 
 
 
public int getHeight() {
    return height;
}
 
 
 
public void setHeight(int height) {
    if(height>0)
    this.height = height;
    else this.height=0;
}
 
 
 
public int getWeight() {
    return weight;
}
 
 
 
public void setWeight(int weight) {
    if(weight>0)
    this.weight = weight;
    else this.weight=0;
}
 
 
 
public Czlowiek(String name, String surname, int age, int height, int weight) {
    super();
    setName(name);
    setSurname(surname);
    setAge(age);
    setHeight(height);
    setWeight(weight);
}
 
 
 
@Override
public String toString() {
    return "Czlowiek [name=" + name + ", surname=" + surname + ", age=" + age + ", height=" + height + ", weight="
            + weight + "]";
}
 
 
 
public static void biegnij(){
    System.out.println("Biegnę");
}
 
 
 
@Override
public int compareTo(Czlowiek czl) {
    if (this.age<czl.age) return -1;
    else if (this.age>czl.age) return 1;
    return 0;
}
 
}

Comments