Cat and Mouse Java Program

Avg Bid (USD)
Project Budget (USD)
$30 - $250

Project Description:
The file must be called (driver program) (which extends Mammal) (which extends Mammal)

Overall Requirements

Write a program that simulates the battle between a cat and mice.

Use this class hierarchy:


· Kills 1 mouse a day

· Does not reproduce


· Have a chance to reproduce as long as conditions are met

· Reproduction only happens when mice are over 1 and 1 of each sex is present

Simulation Control

· Simulation continues as long as population is greater than 1 and less than 10

Driver main method should be as shown below: (replacing comment with missing piece)

import java.util.ArrayList;

public class LastFirstWeek5CatMouse
public static void main(String [] args)

Cat sylvester = new Cat();
ArrayList mice = new ArrayList();
mice.add(new Mouse());
mice.add(new Mouse());
mice.add(new Mouse());

while (mice.size() >1 && mice.size() < 10)
for (Mouse m:mice)

Output code should output:

Depending on if the population of mice is greater than or equal 10:

Mice RULE, Cats Drool Mice Population: ## (integer value)
Cats RULE, Mice Drool Cat Weight (in mice): ##.## (double value, 2 decimal places)

Output should output results 10 times. Modification of or before while loop may be required. See sample output below. class

Instance variables:

name (string)
age (integer)
weight (double)
isMale (Boolean)

Mammal constructor : (default constructor)

Set age to 1.

grow method :

Increases age of mammal by 1.

Accessor / mutator methods for each instance variable above:

Set or returns values as appropriate for data type specified. class

eat method: (receive mouse arraylist as argument)

Randomly removes a mouse from the population 70% of the time and increases cat weight by the chosen mouse weight. Only increase weight if mouse is removed/eaten. (See chapter 5, lottery example, for random example)

grow method:

Set the cats age to the current age plus 1. (use accessor/mutator methods) class

Mouse constructor: (default constructor)

Randomly choose sex and assign to isMale as appropriate.

Set age to 1.

Set weight to 1.

grow method:

Increase age of mouse by 1 and weight of mouse by 1% of current weight.

mate method: (static method, receive mouse arraylist as argument)

Randomly choose 2 mice objects from arraylist and if conditions are correct, proceed with mating.

Successful mating conditions are:

· 1 male, 1 female mouse

· Both mice older than 1 day

If successful mating, randomly create between 0-4 mice and append to arraylist received as argument.

Sample session (requires no user input):

Mice RULE, Cats Drool Mice Population: 11
Cats RULE, Mice Drool Cat Weight (in mice): 2.03
Mice RULE, Cats Drool Mice Population: 10
Cats RULE, Mice Drool Cat Weight (in mice): 2.05

Press any key to continue . . .

As always, you should:

Limit your use of class variables and instance variables – only use them if appropriate.
Use appropriate modifiers for your methods. The modifiers we’ve discussed are private, public, static, and final.
Use helper methods if appropriate.
Follow the Java Coding Styles Document including comments and style
Mimic the sample session precisely.

Skills required:
About the employer:
Public Clarification Board
Bids are hidden by the project creator. Log in as the employer to view bids or to bid on this project.
You will not be able to bid on this project if you are not qualified in one of the job categories. To see your qualifications click here.

$ 30
in 0 days
$ 30
in 1 days
$ 30
in 0 days
$ 30
in 0 days
$ 30
in 1 days
Hire csanuragjain
$ 30
in 3 days
Hire msabouri
$ 30
in 1 days
$ 30
in 0 days
Hire kdeveloper5
$ 30
in 0 days
$ 30
in 1 days