Question: Create a class to represent a Farm object containing instances of the Animal objects Farm animals : Animal [ ] farmName : String numAnimals :
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
Farmdefault animals
FarmStringdefault animals
Farmintsize of array
FarmString int
addAnimalAnimal : void
getFarmName : String
setFarmNameString : void
getAnimalint : Animal return null if index is invalid
getNumAnimals : int notice no setter... this is a controlled variable
getFirstAnimal : Animal
getLastAnimal : Animal
getAnimals : Animal
printAllDetails : void prints Farm attributes followed by Animal attributes as formatted below :
"FarmName: s Number of Animals: d Farm Size: d
"Name: s Year of Birth: d Weight: f Gender: c
removeAnimalint : Animal
removeAllAnimals : void
getTotalWeightOfAllAnimals : double
getAverageWeightOfAllAnimals : double
getNumberOfAnimalsAboveWeightdouble : int
getNumberOfAnimalsBelowWeightdouble : int
increaseWeightOfAllAnimals : void
increaseWeightOfAllAnimalsdouble : void
View javadoc for Animal and Farm classes
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
