Cash-back offer from May 7th to 12th, 2024: Get a flat 10% cash-back credited to your account for a minimum transaction of $50.Post Your Questions Today!

Question DetailsNormal
$ 14.00

Unit 5 Chapter 14 Assignment complete solutions correct answers key

Question posted by
Online Tutor Profile
request

Unit 5 Chapter 14 Assignment complete solutions correct answers key

 

Unit 5 Chapter 14 Assignment

Grading Information: This Program is due on Date Specified.

Comments are REQUIRED; flow charts and pseudocode are NOT REQUIRED.

Directions Points

The files must be called <LiFiUnit5Ch14.java> (driver program)

LiFiAnimal.java

LiFiFox.java (which extends LiFiAnimal)

LiFiChicken.java (which extends LiFiAnimal)

The files must be called as specified above, (LiFi = Your Last Initial Your First Initial)

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.

Only submit the .java files needed to make the program run. Do not submit the

.class files or any other files.

5%

Style Components

Include properly formatted prologue, comments, indenting, and other style elements

as shown in Chapter 2 starting page 64 and Appendix 5 page 881-892.

5%

Topics covered in chapter

Topics with * are covered in this assignment.

*Object class

*equals method

toString method

*Polymorphism

Abstract

*Interfaces

Protected access modifier

Basic Requirements

Write a program that simulates the battle between a fox and chickens.

Use this class hierarchy:

Fox

􀁸 Kills 1 chicken a day

20%

􀁸 Does not reproduce

Chicken

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

􀁸 Reproduction only happens when chickens are over 1 and 1 of each sex is

present

Simulation Control

􀁸 Simulation continues as long as chicken population is greater than 1 and less

than or equal 10

􀁸 (if 1 or less, mating can’t happen. If > 10, chickens will overrun the fox)

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

output piece and replacing LiFi with your initials. Add prologue and additional

comments to explain functionality.)

import java.util.ArrayList;

public class LiFiUnit5Ch14

{

public static void main(String [] args)

{

for(int count=0; count<10; count++)

{

LiFiFox foxy = new LiFiFox();

ArrayList< LiFiChicken > chickens = new

ArrayList<LiFiChicken>();

chickens.clearn();

chickens.add(new LiFiChicken());

chickens.add(new LiFiChicken ());

chickens.add(new LiFiChicken ());

chickens.get(0).setSex(true);

chickens.get(1).setSex(false);

chickens.get(2).setSex(false);

while (chickens.size() >1 && chickens.size() < 10)

{

for (LiFiChicken c:chickens)

c.grow();

foxy.grow();

LiFiChicken.mate(chickens);

foxy.eat(chickens);

}

//INCLUDE CODE FOR OUTPUT HERE.

}

}

Output code should output:

Depending on if the population of chickens is less than 1 and greater than or equal

10:

Chickens win - Chicken Population: ## (integer value)

or

Fox wins - Fox Weight (in chickens): ##.## (double value, 2 decimal places)

Output should repeat 10 times.

See sample output below.

LiFiAnimal.java

Instance variables:

name (string)

age (integer)

weight (double)

isMale (Boolean)

LiFiAnimal constructor : (default constructor)

Set age to 1.

grow method :

Increases age of LiFiAnimal by 1.

Accessor / mutator methods for each instance variable above:

Set or returns values as appropriate for data type specified.

10%

LiFiFox.java class

eat method: (receive chickens arraylist as argument)

Randomly removes a chicken from the population 70% of the time and increases

fox weight by the chosen chicken weight. Only increase weight if chicken is

30%

removed/eaten.

grow method:

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

LiFiChicken.java class

LiFiChicken 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 chicken by 1 and weight of chicken by 1% of current weight.

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

Randomly choose 2 chicken objects from arraylist and if conditions are correct,

proceed with mating.

Successful mating conditions are:

􀁸 1 male and 1 female chicken

􀁸 Both chickens older than 1 day

􀂃 If successful mating, randomly create between 0-4 chickens and

append to arraylist received as argument

30%

NOTE: Complete your activity and submit it by clicking “Submit Assignment”

Total Percentage 100%

Sample

Your output will vary based on the random numbers generated.

Sample session (requires no user input):

Available Answer
$ 14.00

[Solved] Unit 5 Chapter 14 Assignment complete solutions correct answers key

  • This solution is not purchased yet.
  • Submitted On 15 Jan, 2017 08:39:45
Answer posted by
Online Tutor Profile
solution
Unit 5 Chapter 14 Assignment complete solutions correct answers key Unit 5 Chapter 14 Assignment Grading Information: This Program is due on Date Specified. Comments are REQUIRED; flow charts and pseudocode are NOT REQUIRED. Directions Points The files must be called (driver program) LiFiAnimal.java LiFiFox.java (which extends LiFiAnimal) LiFiChicken.java (which extends LiFiAnimal) The files must be called as specified above, (LiFi = Your Last Initial Your First Initial) 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. Only submit the .java files needed to make the program run. Do not submit the .class files or any other files. 5% Style Components Include properly formatted prologue, comments, indenting, and other style elements as shown in Chapter 2 starting page 64 and Appendix 5 page 881-892. 5% Topics covered in chapter Topics with * are covered in this assignment. *Object class *equals method toString method *Polymo...
Buy now to view the complete solution
attachment
Attachment
Other Similar Questions
User Profile
Assig...

Sophia college algebra unit 5 challenge 4!Rated A+ Answers

Your answers are attached. Thanks for purchasing this assignment!...
User Profile
Quali...

PSYCHOLOGY UNIT 5 CHALLENGE 3 MEMORY, COMPLETE WITH QUESTIONS AND ANSWERS.

PSYCHOLOGY UNIT 5 CHALLENGE 3 MEMORY, COMPLETE WITH QUESTIONS AND ANSWERS.Gaining access to information or events from the past occurs during which of the following stages of memory?  a.) The encoding stage  b.) Th...
User Profile
maste...

FIN305 Unit 5 Chapter 7 Quiz Latest 2018 (A+++ Answer)

Question Question 1 1 out of 1 points Under the Employee Retirement Income Security Act, a company can be liable for its pension plan up to 30% of its net worth 30% of pension liabilites 30% of liabilities 40% of its net wor...
User Profile
vpqnr...

Unit 5 Chapter 14 Assignment complete solutions correct answers key

Unit 5 Chapter 14 Assignment complete solutions correct answers key Unit 5 Chapter 14 Assignment Grading Information: This Program is due on Date Specified. Comments are REQUIRED; flow charts and pseudocode are NOT REQUIRED....
User Profile
AceTu...

Unit 5 Chapter 14 Assignment | Solution

Public abstract class LiFiPizza { public LiFiPizza() { this.cost = 5; } public String getType() { return type; } public void setType(String ...

The benefits of buying study notes from CourseMerits

homeworkhelptime
Assurance Of Timely Delivery
We value your patience, and to ensure you always receive your homework help within the promised time, our dedicated team of tutors begins their work as soon as the request arrives.
tutoring
Best Price In The Market
All the services that are available on our page cost only a nominal amount of money. In fact, the prices are lower than the industry standards. You can always expect value for money from us.
tutorsupport
Uninterrupted 24/7 Support
Our customer support wing remains online 24x7 to provide you seamless assistance. Also, when you post a query or a request here, you can expect an immediate response from our side.
closebutton

$ 629.35