2 of 2
Paper No: 1
Flower
+unitPrice:int
unitPrice: final static variable contains price for each Flower.
+bloom at(int):int
+fade at(int):int
+price(int):int
You create a Daisy class that implements the Flower interface( in the default package) as follows
Daisy
Where:
You need to override all abstract functions in Flower interface as follows:
bloom_at(int currHour): int - Calculate at what hour(from currHour) a flower will bloom (all hours are in 24 hours format). Return bloomHour = currHour 5. If bloomHour>24 bloomHour=24 to ensure valid format of bloomHour. For example: if we set currHour is 23:00 at night, then it will bloom at 23:00+5 -24 4:00 on the next morning day.
fade_at(int currHour):int - Calculate at what hour (fromcurrHour), a flower will be faded (all hours are in 24 hours format). Rerturn fadeHour = currHour + 10. If fadeHour>24→fadeHour-=24 to ensure valid hour format of fadeHour. For example: if we set currHour is 23:00 at night, then it will die at 23:00+10-24 9:00 on the next morning day.
price(int numOfFlower):int - Return the price using this formular: price Flower. unitPrice* numOfFlower
A main program is provided in binary form. You can test with following testcases to check your
code:
Zoom
+ 80%
Close