Hold three twosome fights between cats Create three cats using the class Cat. Hold three pairwise fights between cats. Do not create the class Cat. For the fight, use the method boolean fight(Cat anotherCat). Display the result of each fight.

I got till here but I'm confused about the next part..please help:

public class Solution {
public static void main(String[] args) {
 Cat cat1 = new Cat("Jim", 4, 7 ,3);
 Cat cat2 = new Cat("Sam", 5, 3, 7);
 Cat cat3 = new Cat("Tim", 5, 2, 8);
 cat1.fight(cat2);
 cat2.fight(cat3);
 cat3.fight(cat1);
   //add your code here
}

public static class Cat {

    public static int count = 0;
    public static int fightCount = 0;

    protected String name;
    protected int age;
    protected int weight;
    protected int strength;

    public Cat(String name, int age, int weight, int strength) {
        count++;

        this.name = name;
        this.age = age;
        this.weight = weight;
        this.strength = strength;
    }

    public boolean fight(Cat anotherCat) {
        fightCount++;

        int agePlus = this.age > anotherCat.age ? 1 : 0;
        int weightPlus = this.weight > anotherCat.weight ? 1 : 0;
        int strengthPlus = this.strength > anotherCat.strength ? 1 : 0;

        int score = agePlus + weightPlus + strengthPlus;
        return score > 2; // return score > 2 ? true : false;
    }
}

}

asked 23 Apr '15, 07:33

RashPeti's gravatar image

RashPeti
112
accept rate: 0%


Read the task. I dont see you displayed the result of each fight

link

answered 13 May '15, 03:22

dimashaman's gravatar image

dimashaman
262
accept rate: 20%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×30
×24
×11

Asked: 23 Apr '15, 07:33

Seen: 1,182 times

Last updated: 13 May '15, 03:22