Name: ____________________________________________________ Alpha: _____________________

Describe help received: _________________________________________________________________

Download the program: HW06.java, Gyeser.java

This is a nicely written procedural program that simulates the eruption of geysers using a model that basically says that the probability of a given geyser not blowing decreases exponentially day-by-day. Compile and run it as shown below:

~/$ java HW06 2018
3 Smokey 0.05 3 ShortStack 0.09 1 Itchy 0.25 0
Day 1: Itchy
Day 2:
Day 3: Smokey
Day 4: Itchy
Day 5: ShortStack
Day 6:
Day 7: Itchy
Day 8: ShortStack, Itchy
Day 9:
Day 10:
Day 11: Itchy
Day 12: Smokey
Day 13: ShortStack
Day 14:
Day 15: Itchy
Day 16: Itchy
Day 17: Smokey, ShortStack
Day 18:
Day 19:
Day 20: ShortStack, Itchy

  1. [10pts] Describe one way in which the above program violates the principle of encapsulation?
  2. [10pts] Describe one way in which the above program violates the principle of information/data hiding?
  3. [70pts] Rewrite the above program as a proper object-oriented program — at least as far as we know how at this point. That means proper use of encapsulation and data/information hiding. The rules are simple:
    1. the input/output behavior of the program stays the same
    2. the main() for the program stays in class HW06
    3. the class Geyser remains in its own file, i.e. not an inner class of HW06
    4. the principles of encapsulation and information/data hiding are followed to the utmost — no public data members for example
  4. [10pts] Given your rewriting, what is the "interface" to your class Geyser?
Turn in: a printout of this worksheet with your answers to written questions, a codeprint printout of the source code for your rewritten question, and a screen capture of your program running on the same input as shown avove (your results should be the same!).