Suppose you have a Town class that describes the demographics of small towns. The vital statistics described by this class are numberOfAdults and numberOfChildren. These vital statistics are encapsulated and not directly accessible from outside the class.
a) Write the following methods for
class Town:i. An
initializemethod that establishes initial values of instance variables. Assume thatinitializegathers all the data it needs by prompting for and inputting values from a user.ii. A
simulateBirthmethod that simulates the birth of one child.iii. A
printStatisticsmethod that prints out the current vital statistics.b) Write a main method for a separate driver class that does the following:
i. Creates a town named
newHomeii. Calls
initializeto establish initial values of instance variables fornewHome.iii. Simulates the birth of a pair of twins.
iv. Prints out
newHome’s vital statistics.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.