Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class People implements Comparable<People>{
- private String imie;
- private String nazwisko;
- private int wiek;
- public int getWiek() {
- return wiek;
- }
- public void setWiek(int wiek) {
- this.wiek = wiek;
- }
- People(String imie, String nazwisko, int wiek){
- this.imie = imie;
- this.nazwisko = nazwisko;
- this.wiek = wiek;
- }
- public String getImie() {
- return imie;
- }
- public void setImie(String imie) {
- this.imie = imie;
- }
- public String getNazwisko() {
- return nazwisko;
- }
- public void setNazwisko(String nazwisko) {
- this.nazwisko = nazwisko;
- }
- @Override
- public int compareTo(People o) {
- if(this.wiek == o.wiek){
- return 0;
- }
- else if(this.wiek > o.wiek){
- return 1;
- }
- else{
- return -1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement