Find Jobs
Hire Freelancers

Cat and Mouse Java Program

$30-250 USD

In Progress
Posted over 11 years ago

$30-250 USD

Paid on delivery
The file must be called (driver program) [login to view URL] [login to view URL] (which extends Mammal) [login to view URL] (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 [login to view URL]; public class LastFirstWeek5CatMouse { public static void main(String [] args) { Cat sylvester = new Cat(); ArrayList mice = new ArrayList(); [login to view URL](new Mouse()); [login to view URL](new Mouse()); [login to view URL](new Mouse()); [login to view URL](0).setSex(true); [login to view URL](1).setSex(false); [login to view URL](2).setSex(false); while ([login to view URL]() >1 && [login to view URL]() < 10) { for (Mouse m:mice) [login to view URL](); [login to view URL](); [login to view URL](mice); [login to view URL](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. [login to view URL] 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. [login to view URL] 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) [login to view URL] 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.
Project ID: 2660077

About the project

22 proposals
Remote project
Active 12 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
Hi, I'd like to do this project please.
$30 USD in 0 day
5.0 (158 reviews)
6.0
6.0
22 freelancers are bidding on average $30 USD for this job
User Avatar
Please check INBOX
$30 USD in 0 day
4.9 (269 reviews)
7.0
7.0
User Avatar
Hi, I will complete this ASAP
$30 USD in 1 day
4.8 (157 reviews)
6.3
6.3
User Avatar
please check your inbox. Thanks
$30 USD in 0 day
4.6 (63 reviews)
5.7
5.7
User Avatar
I can help you, please check your pm.
$30 USD in 1 day
4.8 (40 reviews)
5.4
5.4
User Avatar
hi i can do this contact if interested
$30 USD in 3 days
4.9 (20 reviews)
5.1
5.1
User Avatar
Ready to finish this asap
$30 USD in 1 day
5.0 (41 reviews)
4.8
4.8
User Avatar
Ready to do it. Thanks.
$30 USD in 0 day
4.9 (78 reviews)
4.6
4.6
User Avatar
Hi, I can do this task in 2-3 hours
$30 USD in 0 day
5.0 (4 reviews)
4.2
4.2
User Avatar
Let me help you. Please check PMB!
$30 USD in 1 day
5.0 (12 reviews)
3.7
3.7
User Avatar
I'm ready to work on your project
$30 USD in 0 day
5.0 (4 reviews)
2.9
2.9
User Avatar
Hi, ready to start.
$30 USD in 0 day
4.3 (6 reviews)
2.7
2.7
User Avatar
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
5.0 (2 reviews)
2.4
2.4
User Avatar
HI, I can do this. Ready to start now. Thanks.
$30 USD in 1 day
4.8 (3 reviews)
2.1
2.1
User Avatar
Hi, I can do this very quickly.
$30 USD in 1 day
5.0 (3 reviews)
1.8
1.8
User Avatar
Hello, We have the experience necessary to finish this project fast and with great quality.
$30 USD in 1 day
5.0 (3 reviews)
1.8
1.8
User Avatar
I'm ready to work. Please kindly check your PM.
$30 USD in 0 day
5.0 (1 review)
1.7
1.7
User Avatar
I can complete this project to the exact specifications that are outlined. Thanks.
$30 USD in 1 day
5.0 (2 reviews)
1.6
1.6
User Avatar
Please check my PM
$30 USD in 1 day
0.0 (0 reviews)
0.0
0.0
User Avatar
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.0 (0 reviews)
0.0
0.0
User Avatar
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.0 (0 reviews)
0.0
0.0

About the client

Flag of UNITED STATES
San Antonio, United States
5.0
9
Payment method verified
Member since Oct 4, 2012

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.