In this lab, you'll take a working "Magic 8-Ball" and give it multiple states - normal, empathetic, angry and sarcastic. Each state will be implemented as a different class, which inherit from the default behavior that I already wrote.
Create a new C# console application, and paste this starter code into Program.cs: Program.cs
Since this is a console application, you will only need to commit that code file with your modifications. The repo is here:
https://cssvn.utrgv.edu/svn_etomai/201810_3328/lab07_8ball/<username>
Create a new class, AngryOracle
that inherits from Oracle
. Override the update
method so that it always sets the answer to ARGHGHAGHHGH!!!
. In Program.main
, change the code to start with an AngryOracle
, and run the program again. Now it should just be yelling at you all the time.
Next, change back to the default Oracle
, but update it so that if the input is Shouting
(see the helper method Oracle.inputType
, it responds with "Please stop shouting."
. If the user shouts again, then it should switch to AngryOracle
. To make the switch, pay attention to the return value from Oracle.update
and the helper method Program.getOracle
.
Next, make AngryOracle
more interesting. Have it become more angry if the uesr keeps SHOUTING
, stay the same if the user makes STATEMENT
s, and calm back down if the user asks QUESTION
s. When it calms down enough, it should revert back to the default Oracle
.
Create a SarcasticOracle
, which inherits from Oracle
. Update Oracle so that if the user makes a STATEMENT
, it says "That's not a question."
and switches to the sarcastic state, which implements the following behavior:
QUESTION
s by repeating and mocking the question.STATEMENT
s with insults.SHOUTING
by saying "Okay! Okay!"
and going back to the default state.Create an EmpatheticOracle
, which inherits from Oracle
. Update Oracle so that if the user asks three QUESTION
s in a row, is switches to the empathetic state, which implements the following behavior:
STATEMENT
s and SHOUTING
the same way that the default state does.(For EmpatheticOracle
, you might want to rearrange things in Oracle
so that you don't have to duplicate code. Feel free to create new methods and move things around.