Due: Monday, February 10, 4 PM (in class).
game = (Game)(Class.forName(gameName).newInstance());
in PlayGame.java by the call
game = GameFactory.create(gamename);
The best design hard codes Easy and then tries to load
dynamically. The Exception thrown should be a
GameException. PlayGame needs to be rewritten both the call the
factory method and to catch the possible exception.
Some of you submitted poorly formatted code and got a zero for this part of the assignment.
Arguments for:
Arguments against
The arguments for are much more convincing. I put a PlayerFactory into release 2 of the game package $CS680/games2.
Probably not. That would work for now, when the application is single threaded and only one game can be played at a time. But perhaps when there's a GUI and certainly when there's a web interface multiple games can proceed simultaneously and singleton's won't work.
114 m = ((ComputerPlayer)player).findbest(g);in PlayGame.java when the ComputerPlayer is an instance of class Speedy and the Game is Easy. (I haven't done this myself yet. It may be quite complex. If it gets too long, you may fudge some of the deeper stuff as long as you show clearly that you really understand how a UML sequence diagram works.)
Leave source code in a hw2 subdirectory of your cs680 course directory. Do not alter any permissions.