63 081
Assignments Done
99,1%
Successfully Done
In July 2018

Answer to Question #54414 in Java | JSP | JSF for josh

Question #54414
Write a program that models a snail ranch, as follows.

+REPRODUCTION_RATE : int = 100 {readOnly}
+BASE_POPULATION : int = 200 {readOnly}
-population : int

+SnailRanch(population : int)
+getPopulation() : int
+breed() : void
+harvest() : int

getPopulation() returns the current population, breed() causes the snails to breed
harvest() harvests the snails, returning the yield, the number of snails that could be harvested,
reducing the population to no lower than BASE POPULATION

REPRODUCTION RATE is the number of children per pair of snails
BASE POPULATION is the number of snails to be left in the ranch after a harvest, population is the current population of the ranch
SnailRanch(int) is a constructor that establishes a ranch with an initial population

Implement a Main class that reads a file of events and prints the events, the current
population after each event, and after all events have occurred, prints the total yield from the ranch.The name of the file of events will be supplied as a command line argument.

if the file txt contains these events:
stock 100
breed
breed
harvest
breed
harvest

then a run of the program would look like this:
$java Main log.txt stock 100 breed 5100 breed 260100 harvest 200 breed 10200 harvest 200 total yield = 269900$
The first event will always be "stock" with the initial population of the ranch.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Assignment Expert
03.09.15, 18:04

josh
02.09.15, 10:22

getPopulation() returns the current population, breed() causes the snails to breed
harvest() harvests the snails, returning the yield, the number of snails that could be harvested,
reducing the population to no lower than BASE POPULATION

josh
02.09.15, 09:44

REPRODUCTION RATE is the number of children per pair of snails
BASE POPULATION is the number of snails to be left in the ranch after a harvest, population is the current population of the ranch
SnailRanch(int) is a constructor that establishes a ranch with an initial population