Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use Java, Thank you. 8-2 Create a class to represent a Farm object containing instances of the Animal objects Farm - animals : Animal

Please use Java, Thank you. 8-2
image text in transcribed
Create a class to represent a Farm object containing instances of the Animal objects Farm - animals : Animal [] - farmName : String - numAnimals : int //calculated controlled variable no setter + Farm() + Farm(String) //default 10 animals + Farm(int) I/default 10 animals + Farm(String, int) //size of array + addAnimal(Animal) : void + getFarmName(): String + setFarmName(String) : void + getAnimal(int) : Animal //return null if index is invalid + getNumAnimals() : int + getFirstAnimal(): Animal Iotice no setter... this is a controlled variable + getLastAnimal(): Animal + getAnimals() : Animal[] + printAllDetails() : void II prints Farm attributes followed by Animal attributes as formatted below: I/ "FarmName: \%20s | Number of Animals: \%4d | Farm Size: \%4dln" + removeAnimal(int) : Animal + removeAllAnimals() : void + getTotalWeightOfAllAnimals() : double + getAverageWeightOfAllAnimals() : double + getNumberOfAnimalsAboveWeight(double) : int + getNumberOfAnimalsBelowWeight(double) : int + increaseWeightOfAllAnimals() : void + increaseWeightOfAllAnimals(double) : void View javadoc for Animal and Farm classes

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Murach's SQL Server 2012 For Developers

Authors: Bryan Syverson, Joel Murach, Mike Murach

1st Edition

1890774693, 9781890774691

More Books

Students also viewed these Databases questions

Question

What are some limitations of internal control?

Answered: 1 week ago