Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started