public class Cat
{
public String name;
public int age;
public int weight;
public int strength;
public static void main(String[] args)
{
Cat cat1 = new Cat();
cat1.age = 4;
cat1.strength = 20;
cat1.weight = 20;
cat1.name = "Cat1";
Cat cat2 = new Cat();
cat2.name = "Cat2";
cat2.weight = 15;
cat2.strength = 15;
cat2.age = 5;
cat1.fight(cat2);
}
public Cat()
{
this.name = name;
this.age = age;
this.weight = weight;
this.strength = strength;
}
public boolean fight (Cat anotherCat)
{
if(this.strength > anotherCat.strength)
{
return true;
}
else return false;
}
}
package com.codegym.task.task05.task0502;
/*
Implement the fight method
*/
public class Cat
{
public String name;
public int age;
public int weight;
public int strength;
public static void main(String[] args)
{
Cat cat1 = new Cat();
cat1.age = 4;
cat1.strength = 20;
cat1.weight = 20;
cat1.name = "Cat1";
Cat cat2 = new Cat();
cat2.name = "Cat2";
cat2.weight = 15;
cat2.strength = 15;
cat2.age = 5;
cat1.fight(cat2);
}
public Cat()
{
this.name = name;
this.age = age;
this.weight = weight;
this.strength = strength;
}
public boolean fight (Cat anotherCat)
{
if(this.strength > anotherCat.strength)
{
return true;
}
else return false;
}
}