Forums Register Login

Random generation

+Pie Number of slices to send: Send
hi, i need help with this question
Design and implement a hierarchy for the following weather warnings: Normal, HighWind, Storm, Tornado, Snow, SnowStorm, Blizzard, Frost, Mist. Each class/object should be able to respond to the following method calls: ``report'' and ``action''. Write a driver program that asks the user for the number of weather warnings (s)he wants to create. Use this input to randomly create the necessary objects and store them in a container class. Use polymorphism to print out the reports of each of the warnings and associate actions.the proper use of abstract classes, inheritance and polymorphism is critical
I have done the following hierarchy
Weather (is at the top of hier. also an abstract class)
|
Normal , Snow, Highwind, mist, frost (they all extend from weather)
|
|snowstorm, blizzard(extend from snow)|,|Storm, Tornado(extend from highwind)|
what i wanna know is how to go about writing the driver programme.
+Pie Number of slices to send: Send
Here's some pseudocode which may point you in the right direction:

If you've overriden the toString() method of each of your classes so that it displays the proper weather warning, something like the above will work. Of course there are a million ways to do something like this, for example you could use an array instead of the static ints, but the above is an easy to read and easy to understand way of approaching a problem such as this.
HTH
[ January 06, 2004: Message edited by: Jason Menard ]
+Pie Number of slices to send: Send
thanks ill give it a go
Watchya got in that poodle gun? Anything for me? Or this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 713 times.
Similar Threads
Inheritance with two Children?
TAAPMAAN
Abstract classes vs. interfaces
Polymorphism: to overriding, not to overloading
coding Excercise
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 08:44:05.