package pl.codegym.task.task05.task0502;
/*
Zaimplementuj metodę walka
*/
public class Kot {
public int wiek;
public int waga;
public int sila;
public int moc;
public Kot(int wiek, int waga, int sila) {
this.wiek = wiek;
this.waga = waga;
this.sila = sila;
this.moc = this.wiek + this.waga + this.sila;
}
public int getWiek() {
return wiek;
}
public int getWaga() {
return waga;
}
public int getSila() {
return sila;
}
public int getMoc() {
return moc;
}
public boolean walka(Kot innyKot) {
if (this.moc > innyKot.moc)
return true;
else
return false;
}
public static void main(String[] args) {
Kot kot1 = new Kot(10,10,3);
Kot kot2 = new Kot(5,5,5);
int kot1wiek = kot1.getWiek();
int kot1waga = kot1.getWaga();
int kot1sila = kot1.getSila();
int kot2wiek = kot2.getWiek();
int kot2waga = kot2.getWaga();
int kot2sila = kot2.getSila();
System.out.println(kot1.walka(kot2));
System.out.println(kot2.walka(kot1));
}
}
Sebastian
Poziom 17
What I do wrong?
Dyskutowane
Komentarze (1)
- Popularne
- Najnowsze
- Najstarsze
Musisz się zalogować, aby dodać komentarz
Misiu
27 lipca 2020, 19:30
Klasa Kot musi mieć konstruktor bez parametrów.
Kod nie ma wyświetlać czegokolwiek.
0