Find Jobs
Hire Freelancers

Cat and Mouse Java Program

$10-30 USD

Closed
Posted over 9 years ago

$10-30 USD

Paid on delivery
Assignment - Cat & Mouse Island Okay, we'll be playing a little game. Imagine an island (okay, a 5x5 grid). This island is surrounded by water, and there are 6 bridges off of the island. On the island is a hungry cat, and a scared mouse. The cat is hungry, but it's his island, and he won't leave it. The mouse, of course, will escape, if he finds a bridge. Sadly, in his fright, he might run into the water and drown (had a terrible experience as a young mouse, never learned to swim). At the beginning of the game, both the cat and the mouse are placed randomly on the island proper. The bridges are roughly evenly–spaced, 2 on each side. Island as a grid I'd recommend extending the coordinate system to include the bridges and the immediately surrounding water. Create an Animal abstract class. It'll have a protected attribute, of type Point, its location on the map, and a private String attribute, the animal's name. You'll need to add other attributes, as well. It'll define these methods: String getName() Point getLocation() void setStartLocation() Animal will have a single constructor, that takes a String (the animal's name), a Random object (the single random number generator that everybody will use). It'll store these values as instance variables (attributes). Animal( String name, Random rng ) It'll also declare an abstract method: void move() Inherit from Animal to create a Cat class; override the move method, to randomly move north, south, east or west. Again, the cat will not jump in the water, nor will it cross a bridge. It'll have a single constructor, that takes a String, calls the parent class' constructor to set the name. Also create a Mouse class from Animal; again, override the move method, to randomly move north, south, east or west. If the mouse drowns or escapes he won't make any more moves. You might need to keep (and initialize) another attribute, to track the mouse's mobility. It also has a single constructor, to set the name. Finally, create a Chase class, which'll have a static playGame method, which plays a single game, and returns a status (cat had a snack, mouse escaped, mouse drowned). Randomly choose a starting point for each animal. To be fair, if they start on the same spot, pick another start for one of the animals. The mouse moves first; if he lands on a square that has a bridge he escapes, the game is done. If he falls in the water, the game is also done. Then the cat gets to move; if he lands on the same spot, he gets a snack, and play is over. In the Chase class, write a main method which'll play the game 30 times, and report the outcome, to standard out, in a single line. You may add any (non-public) helper methods to any class that you find useful. Picking random numbers You'll want to create a Random object, and use the nextInt( n ) method. There will be only one generator for the entire program; create it (once) in the main driver, and pass it to your animals as you create them. Input None Output You are to print the result of each of 30 trials to stdout, one result per line, single spaced. After all the trials print a blank line, then report 3 statistics: The % of times the mouse escaped, drowned, and was eaten. What to hand in [login to view URL] [login to view URL] [login to view URL] [login to view URL] README – (opt)
Project ID: 6757626

About the project

18 proposals
Remote project
Active 9 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
18 freelancers are bidding on average $29 USD for this job
User Avatar
A proposal has not yet been provided
$35 USD in 2 days
5.0 (132 reviews)
8.0
8.0
User Avatar
Hi, I am placing my bid on your project because I have read the requirements and I am confident enough with my Java and algorithm skills. I am focused mostly on doing computer science work here in freelancer.com and I would like to help you get this project done if you would give me the opportunity. I am a computer science professor and practitioner and this assignment is one of the fields that I teach very well so I can assure you an accurate result. Let me know if you are interested so I can start. Thanks.
$30 USD in 1 day
5.0 (1082 reviews)
7.6
7.6
User Avatar
TOP Ranked Java programmer with 600+ reviews. I read the details and will provide you well commented code. Thanks
$30 USD in 1 day
4.8 (441 reviews)
7.4
7.4
User Avatar
A proposal has not yet been provided
$25 USD in 1 day
4.9 (630 reviews)
6.8
6.8
User Avatar
hey there, we went through this Java assignment (Cat & Mouse)...Please let us know when do you want this completed, please reply, thank you !
$38 USD in 2 days
4.9 (99 reviews)
5.6
5.6
User Avatar
Hi! I am professional C/C++/C#/Java programmer. I can do this project with highest quality. Best Regards, Szymszteinsl
$50 USD in 3 days
4.7 (53 reviews)
5.9
5.9
User Avatar
I am an expert in java and willing to discuss further about the project specifications and needs .
$54 USD in 2 days
4.9 (22 reviews)
5.5
5.5
User Avatar
Hello, I am a software engineer experienced in Java, i can complete your project within 24 hours from awarding.
$30 USD in 1 day
5.0 (27 reviews)
4.9
4.9
User Avatar
experienced Java programner, with great experience on the domian. please contact me for more information
$25 USD in 1 day
5.0 (7 reviews)
3.6
3.6
User Avatar
Hey! Pretty clear requirements. I can make this for you in one day. Does the island size need to be changeable or will it stay 5x5? Because if it can change the bridges should be calculated dynamically.. Kind regards.
$15 USD in 1 day
5.0 (14 reviews)
3.3
3.3
User Avatar
Hello, I am a mainly a web professional but I have good expertise in java also. Let me know if you are interested. Thank you Manoj Baruah
$30 USD in 1 day
5.0 (3 reviews)
2.5
2.5
User Avatar
I am a Java developer by trade. This particular problem should not be difficult. Thank You for your consideration.
$25 USD in 1 day
5.0 (1 review)
2.6
2.6
User Avatar
I've been studying computer science for 4 years and have successfully completed many assignments like yours. I can code your cat mouse program within an hour. Please contact me for further information.
$13 USD in 0 day
4.8 (2 reviews)
2.2
2.2
User Avatar
A proposal has not yet been provided
$50 USD in 1 day
5.0 (3 reviews)
1.9
1.9
User Avatar
Requirements are clear and task seems to be easy for a commercial programmer. However it will be a little time consuming. The price is so low because of the project characteristic. It would be a lot of fun :). Do you need any kind of GUI?
$15 USD in 3 days
0.0 (0 reviews)
0.0
0.0
User Avatar
Bir öneri henüz sağlanmadı
$10 USD in 1 day
0.0 (0 reviews)
0.0
0.0
User Avatar
I have been in this industry for 4 years and such jobs are my daily practice. This is my first time on this site and hence you can see that I do not have any ratings/testimonials to show you. I can assure you that if you work with me once, you will always work with me for these kind of projects.
$15 USD in 1 day
0.0 (0 reviews)
0.0
0.0
User Avatar
This is a simple enough project, any one of us freelancers could probably do this. I certainly can, and quickly at that. The point is, none can be "better" at this than the others. I can guarantee that it gets done, the code will be easy to understand and I can do as much or as little commenting as you like. For any details surrounding the task, we can discuss that before I get started. Feel free to contact me about anything!
$25 USD in 1 day
0.0 (0 reviews)
0.0
0.0

About the client

Flag of UNITED STATES
Philadelphia, United States
0.0
0
Member since Nov 20, 2014

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.