Ask Management Information System Expert

Inheritance

One of the topics covered this week is "Inheritance". The chapter shows the Person/Employee example, what are some other examples that could use Inheritance? Read section 12.3-12.4 and come up with your own example of inheritance. Do not copy the examples from the textbook or other sources. Explain your example in a paragraph or two, longer if you need to. After you do that, you must show how the inheritance relation will be reflected in Java code. In other words, you are not required to write a complete set of classes and their contents, but at the minimum you must show the inheritance relation between the various classes that make up your example.

Directions

The files must be called cLnFnUnitS.java> (driver program) LnFnAnimal.java

LnFnFox.java (which extends LnFnAnimal) LnFnChicken.java (which extends LnFnAnimal)

The files must be called as specified above, (LnFn = Your Last Name Your First Name. For example the Instructor will create GuillermoTonsmannFox.java and others similarly.)

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.

Basic Requirements and Driver class

Use this class hierarchy: Fox and Chicken are children classes of the Animal class. A Fox

• Will kill 1 chicken a day
• Does not reproduce

A 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

The simulation control inside the main method on LnFnUnit5 will do the following:

• Simulation will continue 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 LnFn with your initials. Add prologue and additional comments to explain functionality.)

import java.util.ArrayList;
public class LnFnUnit5 {
public static void main(String args) { for(int count=0; count<10; count++) { LnFnFox foxy = new LnFnFox();
ArrayList< LnFnChicken > chickens = new ArrayList();

chickens.clear();

chickens.add(new LnFnChicken()); chickens.add(new LnFnChicken 0);

chickens.add(new LnFnChicken 0); chickens.get(0).setSex(true);
chickens.get(1).setSex(false);
chickens.get(2).setSex(false);
while (chickens.size() >1 && chickens.size() < 10) { for (LnFnChicken c:chickens) c.grow();
foxy.grow();
LnFnChicken.mate(chickens); foxy.eat(chickens);
}
//INCLUDE CODE FOR OUTPUT HERE. }II end of for
} // end of main
} // end of class

The program will output one of the following messages:

Chickens win - Chicken Population: 14

(if chicken population is greater than or equal to 10, t/c/4 is an integer value) OR

Fox wins - Fox Weight (in chickens): #14.144

(if chicken population is less than 10, *kg* is a double value, 2 decimal places)

Because the output will be inside the main for loop, the output will be repeated 10 times. See sample output below.

Remember to use get and set methods in all classes whenever you want to obtain (get) or change (set) any of the attributes of your objects.

LnFnAnimaljava class

The Animal class will have the following attributes:

• name

age (an integer number that represents the days of age)

weight (a double number that represents a weight in pounds)

maleSex (a boolean variable that is true, if the Animal is male, false otherwise)

All attributes should be private and each one should have public appropriate accessor (get) and mutator (set) methods.

A default constructor will initialize the age of every Animal to 1 day.

The Animal class should also have a method named grow with no parameters that increases the age of the Animal by one.

LnFnFox.java class

LnFnFox constructor: (default constructor)

It sets the fox's age to a random number between 400 to 900 days.

It sets the fox's weight to a random number between 30 to 60 pounds. It randomly sets the fox's sex.

The Fox class will include the method named eat to do the following: eat method: It receives an Arraylist of Chicken objects as argument.

It randomly removes a chicken from the population 70% of the time and increases fox weight by the chosen chicken weight. It only increases the fox's weight if the chicken is removed/eaten.

LnFnChicken.java class

LnFnChicken constructor: (default constructor)

It sets the chicken's age to 1 day and the chicken's weight to 1 pound.

It randomly sets the chicken's sex.

The Chicken class will include the following methods:

grow method:

It overrides the grow method from the Animal class to increase the chicken's age by 1 and the chcicken's weight by 1% of its current weight.
mate method: An static method that receives an Arraylist of Chicken objects as argument.

It randomly chooses 2 Chicken objects from the Arraylist and if conditions are correct, it proceeds with mating.
Successful mating conditions are:

- 1 male and 1 female chicken

- Both chickens older than 1 day

§ If successful mating occurs, create a random number (between 0 to 4 ) of new Chicken objects, and append them to the Arraylist received as argument.

Management Information System, Management Studies

  • Category:- Management Information System
  • Reference No.:- M91734033
  • Price:- $20

Priced at Now at $20, Verified Solution

Have any Question?


Related Questions in Management Information System

Search the csu library the internet or any specific

Search the CSU library, the Internet, or any specific websites, and scan IT industry magazines to find an example of an IT project that had problems due to organizational issues. Write a paper summarizing the key stakeho ...

Question how can company protect the new emerging

Question : How can company protect the new emerging technology ventures from profit pressures of the parent organization (APA format required, Turntin check required . Minimum 250 words essay) How do companies overcome l ...

Communication and team decision makingpart 1 sharpening the

Communication and Team Decision Making Part 1: Sharpening the Team Mind: Communication and Collective Intelligence A. What are some of the possible biases and points of error that may arise in team communication systems? ...

Question provide an explanation of ifwherehow does active

Question : Provide an explanation of if/where/how does Active Directory support network security,14 pages (2,000-2,500) in APA format. Include abstract and conclusion. Do not include wikis, message boards, support forums ...

Question how companies could effectively use emerging

Question : How companies could effectively use emerging technology to win over its competitors. APA format required. 250 words essay required. The response must be typed, single spaced, must be in times new roman font (s ...

Question how customers could effectively use emerging

Question : How customers could effectively use emerging technology to win over its customers. APA format required. 250 words essay required. turntin check require. The response must be typed, single spaced, must be in ti ...

Part 1 - create an 8 slide powerpoint presentation on

Part 1 - Create an 8 slide PowerPoint presentation on foundational concepts specific to physical security. Part 2 - Write 4 pages detailing the framework for the design of an integrated data center. Assessment Instructio ...

In chapter 2 of the text - managing amp using information

In Chapter 2 of the text - Managing & Using Information Systems: A Strategic Approach, the chapter discusses why information systems experience failure often because of organizational strategy. A classic example of this ...

Review at least 4 articles on balanced scorecard and

Review at least 4 articles on Balanced Scorecard and complete the following activities: 1. Write annotated summary of each article. Use APA throughout. 2. As an IT professional, discuss how you will use Balanced Scorecar ...

Data resources management questionsq1 the dama dmbok

Data Resources Management QUESTIONS Q1. The DAMA DMBOK textbook describes the following two core activities as part of the Data Architecture management exercise: "Understanding enterprise information needs" and "Develop ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As