Cat and Mouse Java Program

Closed

Description

The file must be called (driver program)

[url removed, login to view]

[url removed, login to view] (which extends Mammal)

[url removed, login to view] (which extends Mammal)

Overall Requirements

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

Use this class hierarchy:

Cat

· Kills 1 mouse a day

· Does not reproduce

Mice

· 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 [url removed, login to view];

public class LastFirstWeek5CatMouse

{

public static void main(String [] args)

{

Cat sylvester = new Cat();

ArrayList mice = new ArrayList();

[url removed, login to view](new Mouse());

[url removed, login to view](new Mouse());

[url removed, login to view](new Mouse());

[url removed, login to view](0).setSex(true);

[url removed, login to view](1).setSex(false);

[url removed, login to view](2).setSex(false);

while ([url removed, login to view]() >1 && [url removed, login to view]() < 10)

{

for (Mouse m:mice)

[url removed, login to view]();

[url removed, login to view]();

[url removed, login to view](mice);

[url removed, login to view](mice);

}

//INCLUDE CODE FOR OUTPUT HERE.

}

}

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)

or

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.

[url removed, login to view] 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.

[url removed, login to view] 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)

[url removed, login to view] 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): [url removed, login to view]

Mice RULE, Cats Drool Mice Population: 10

Cats RULE, Mice Drool Cat Weight (in mice): [url removed, login to view]

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: Java

See more: cat mouse java, cat mouse java program, write program simulates battle cat mice, java cat mouse, java cat driver program, cats mice program java, java cat mouse program, java code cat, cat mouse program, java random default constructor, mammal java program, java helper method example, true results, styles for less, string c plus plus, program requirements document, population of java, java population, java arraylist 1.5, java 1.5 for loop, java 1.5 for each, java 1.4 arraylist, c plus plus string, coding program, sample coding in java

Project ID: #2660077

Awarded to:

it2051229

Hi, I'd like to do this project please.

$30 USD in 0 days
(158 Reviews)
6.0

22 freelancers are bidding on average $30 for this job

eperfections

Please check INBOX

$30 USD in 0 days
(269 Reviews)
7.0
dobreiiita

Hi, I will complete this ASAP

$30 USD in 1 day
(157 Reviews)
6.3
samitXI

please check your inbox. Thanks

$30 USD in 0 days
(63 Reviews)
5.7
buzzcoder

I can help you, please check your pm.

$30 USD in 1 day
(40 Reviews)
5.4
csanuragjain

hi i can do this contact if interested

$30 USD in 3 days
(20 Reviews)
5.1
msabouri

Ready to finish this asap

$30 USD in 1 day
(41 Reviews)
4.8
ranjitsinha

Ready to do it. Thanks.

$30 USD in 0 days
(78 Reviews)
4.6
kdeveloper5

Hi, I can do this task in 2-3 hours

$30 USD in 0 days
(4 Reviews)
4.2
tientaiTA

Let me help you. Please check PMB!

$30 USD in 1 day
(12 Reviews)
3.7
nkigen

I'm ready to work on your project

$30 USD in 0 days
(4 Reviews)
2.9
mmatuszek

Hi, ready to start.

$30 USD in 0 days
(6 Reviews)
2.7
MattGofStP

I have recently done some very similar basic java work and can easily complete this for you in a very short time frame. Thanks for your consideration.

$30 USD in 1 day
(2 Reviews)
2.4
sathish2connect

HI, I can do this. Ready to start now. Thanks.

$30 USD in 1 day
(3 Reviews)
2.1
nexus7x

Hi, I can do this very quickly.

$30 USD in 1 day
(3 Reviews)
1.8
CDErrors

Hello, We have the experience necessary to finish this project fast and with great quality.

$30 USD in 1 day
(3 Reviews)
1.8
fihgu

I'm ready to work. Please kindly check your PM.

$30 USD in 0 days
(1 Review)
1.7
forestcitysoft

I can complete this project to the exact specifications that are outlined. Thanks.

$30 USD in 1 day
(2 Reviews)
1.6
mrchivers

Hey dude, I've been working as a Java developer for over 10 yrs in the finance, telecomms and gaming industries. Let's do this.

$30 USD in 1 day
(0 Reviews)
0.0
JoseHerrera1966

Hi, I´m agreeing with this job. I have very good abilities programming. This work is very easy for my.

$30 USD in 2 days
(0 Reviews)
0.0
kumarmogasale

Please check my PM

$30 USD in 1 day
(0 Reviews)
0.0