PingPonger Class
Create a public class PingPonger
.
A PingPonger
is in one of two states: ping or pong.
You should provide a constructor accepting a String
argument that sets the initial state.
If the passed String
is "ping", the initial state is ping.
If the passed String
is "pong", the initial state is pong.
If the passed String
is not ping or pong, you should throw an IllegalArgumentException
.
Once the PingPonger
has been created, the user should call pong
if the state is ping
and ping
if the state is pong. ping
takes no arguments and returns true
. pong
takes no arguments
and returns false
. If ping
or pong
is called out of order, you should throw an IllegalStateException
.
Here's an example: