How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask ATLProg Your Own Question

ATLProg
ATLProg, Software Engineer
Category: Homework
Satisfied Customers: 8622
Experience:  Expert in Java C++ C C# VB Javascript Design SQL HTML
Type Your Homework Question Here...
ATLProg is online now
A new question is answered every 9 seconds

Answer required by Sunday morning.

Customer Question

 

































The file must be called <LastFirstCatMouse.java> (driver program)
Mammal.java
Cat.java (which extends Mammal)
Mouse.java (which extends Mammal)


Ensure you include ALL files required to make your program compile and run.
I would like to see your .java files only.


If possible, submit all programs as a single .zip file (not required)


Proper coding conventions required the first letter of the class start with a capital letter and the first letter of each additional word start with a capital letter



5%



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 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());
          mice.get(0).setSex(true);
          mice.get(1).setSex(false);
          mice.get(2).setSex(false);


          while (mice.size() >1 && mice.size() < 10)
          {
              for (Mouse m:mice)
                   m.grow();
              sylvester.grow();
              Mouse.mate(mice);
              sylvester.eat(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.


 



15%



Mammal.java 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.


 



10%



Cat.java 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)


 



30%



Mouse.java 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.


 


 



30%



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. 


Submitted: 1 year ago.
Category: Homework
Expert:  ATLProg replied 1 year ago.
Hi,How soon is this needed?
Customer: replied 1 year ago.

Answer requested within next 24 hours.

Expert:  ATLProg replied 1 year ago.
THIS ANSWER IS LOCKED!
You can view this answer by clicking here to Register or Login and paying $3.
If you've already paid for this answer, simply Login.
ATLProg, Software Engineer
Category: Homework
Satisfied Customers: 8622
Experience: Expert in Java C++ C C# VB Javascript Design SQL HTML
ATLProg and 7 other Homework Specialists are ready to help you
Customer: replied 1 year ago.

Answer is good to go thank you.

Expert:  ATLProg replied 1 year ago.
Welcome !
Please start your question text with "For ATLProg Only" to request me again, next time you need help!
http://www.justanswer.com/homework/expert-atlprog/ - Please bookmark this link to ask new question.

JustAnswer in the News:

 
 
 
Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.
 
 
 

What Customers are Saying:

 
 
 
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
< Last | Next >
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
  • This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex Los Angeles, CA
  • Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP Hesperia, CA
  • I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin Kernersville, NC
  • Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther Woodstock, NY
  • Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know. Robin Elkton, Maryland
  • He answered my question promptly and gave me accurate, detailed information. If all of your experts are half as good, you have a great thing going here. Diane Dallas, TX
 
 
 

Meet The Experts:

 
 
 
  • Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4520
    More than 5000 online tutoring sessions.
< Last | Next >
  • http://ww2.justanswer.com/uploads/BU/BusinessTutor/2012-2-2_115741_Kouki2.64x64.jpg Manal Elkhoshkhany's Avatar

    Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4520
    More than 5000 online tutoring sessions.
  • http://ww2.justanswer.com/uploads/LI/lindaus/2012-6-10_04811_IMG20120609164157.64x64.jpg Linda_us's Avatar

    Linda_us

    Finance, Accounts & Homework Tutor

    Satisfied Customers:

    3121
    Post Graduate Diploma in Management (MBA)
  • http://ww2.justanswer.com/uploads/ComputersGuru/2010-02-13_051118_Photo41.JPG LogicPro's Avatar

    LogicPro

    Engineer

    Satisfied Customers:

    3035
    Expert in Java C++ C C# VB Javascript Design SQL HTML
  • http://ww2.justanswer.com/uploads/lanis/2009-4-1_233717_phput9xef_c1pm.jpg Lani S.'s Avatar

    Lani S.

    Tutor

    Satisfied Customers:

    2457
    Registered Nurse, Internet Researcher, Private Tutor
  • http://ww2.justanswer.com/uploads/chooser77/2009-08-18_162025_Chris.jpg Chris M.'s Avatar

    Chris M.

    M.S.W. Social Work

    Satisfied Customers:

    2341
    Master's Degree, strong math and writing skills, experience in one-on-one tutoring (college English)
  • http://ww2.justanswer.com/uploads/JawaadAhmed/2009-6-27_12137_SIs_SHadi.jpg F. Naz's Avatar

    F. Naz

    Chartered Accountant

    Satisfied Customers:

    1975
    Experience with chartered accountancy
  • http://ww2.justanswer.com/uploads/JK/jkcpa/2011-1-16_182614_jkcpa.64x64.jpg Bizhelp's Avatar

    Bizhelp

    CPA

    Satisfied Customers:

    1873
    Bachelors Degree and CPA with Accounting work experience