Hi as a student I have to create a "Rock-Paper-Scissors" game in Java
.
The player chooses when creating a game if he wants to follow some pre-defined strategies like playing "Rock-Rock-Paper" for example and so I have an Interface to implements differents strategies like RockStrat()
or PaperStrat()
.
When I create a game from the console the user is prompted to type in which strat he wants to follow, let's say, for instance he types in PaperStrat.
His input is read and "PaperStrat" is saved as a String
.
My problem here is I can't figure out how to go from a String
to calling the class PaperStrat
other than by having an IF
condition for each strategy available but that seems way too sloppy.
Any help would be appreciated, Thanks.