Ругается на 52 строчку, не понятно почему, код вроде бы правильно написал. Отсутствует объявление класса, интерфейса или enum-а.
package com.javarush.task.task05.task0502;
/*
Реализовать метод fight
*/
public class Cat {
public int age;
public int weight;
public int strength;
public Cat() {
}
public boolean fight(Cat anotherCat) {
int one = 0;
int two = 0;
if (this.age > anotherCat.age)
one++;
else if (this.age < anotherCat.age)
two++;
else {
one++;
two++;
}
if (this.weight > anotherCat.weight)
one++;
else if (this.weight < anotherCat.weight)
two++;
else {
one++;
two++;
}
if (this.strength > anotherCat.strength)
one++;
else if (this.strength > anotherCat.strength)
two++;
else {
one++;
two++;
}
if (one > two)
return true;
else
return false;
}
}
public static void class main(String[] args) {
Cat one = new Cat();
one.age = 1;
one.weight = 1;
one.strength = 1;
Cat two = new Cat();
two.age = 2;
two.weight = 2;
two.strength =2;
}
}
package com.javarush.task.task05.task0502;
/*
Реализовать метод fight
*/
public class Cat {
public int age;
public int weight;
public int strength;
public Cat() {
}
public boolean fight(Cat anotherCat) {
int one = 0;
int two = 0;
if (this.age > anotherCat.age)
one++;
else if (this.age < anotherCat.age)
two++;
else {
one++;
two++;
}
if (this.weight > anotherCat.weight)
one++;
else if (this.weight < anotherCat.weight)
two++;
else {
one++;
two++;
}
if (this.strength > anotherCat.strength)
one++;
else if (this.strength > anotherCat.strength)
two++;
else {
one++;
two++;
}
if (one > two)
return true;
else
return false;
}
}
public static void class main(String[] args) {
//Cat one = new Cat();
//one.age = 1;
//one.weight = 1;
//one.strength = 1;
//Cat two = new Cat();
//two.age = 2;
//two.weight = 2;
//two.strength =2;
}
}