Hi,
When i want to use the method chat1.combattre(chat2) for instance, when i validate the exercice i have an error like "method combattre mustn't read data from keyboard". very weird.
So i tried with a simple "if" condition which apparently doesn't meet the exercice requirements.
I want to use "this" but i have still a little lack of comprehension about..this ^^.
And i see that i have to use chat1combattre(chat2) and chat2.combattre(chat1). Or do I do what I want ? sometimes statements are not clear.
package fr.codegym.task.task05.task0502;
/*
Implémenter la méthode combattre
*/
public class Chat {
public int age;
public int poids;
public int force;
public Chat() {
}
public boolean combattre(Chat autreChat) {
//écris ton code ici
Chat chat1 = new Chat();
Chat chat2 = new Chat();
chat1.age = 5;
chat1.poids = 6;
chat1.force = 10;
chat2.age = 3;
chat2.poids = 4;
chat2.force = 5;
//chat1.combattre(chat2);
if (chat1.force > chat2.force)
return true;
if (chat2.force < chat1.force)
return false;
return false;
}
public static void main(String[] args) {
}
}