Small Game to illustrate inheritance, polymorphism, abstract classes, and writing to a file.
Work in groups of two:
Think of two types of players for a game that is played in a single line of 20 squares. The players should have one different property, on shared method they do differently, and each have one method of their own. Each player needs to know its own square. Each player's toString method should include the player's type and location as well as all the player's other properties. Each player needs a move method that will take in a number and return the new location. (Different player types should move differently.)
Create a UML class diagram for their players, just on a piece of paper. It must include an abstract player that contains the shared properties and methods.
Create a flow chart using gliffy to describe the move method of the player with the most complex movement.
Code the players.
Create a test class for each player to test the player's move method.
Create a game that has an array of players. It should fill the array with two diffferent player types. Then, it should loop through telling both players to move 1, then 2 and so forth until one wins.
Write the name and location of the winner to a file.
One more enhancement: Add the player's unique method to the game. The player should execute his unique move every turn.
Extra: Code a simple game that involves random winners, using java.util.Random: Your players will throw a 3 sided die and move based on the dice throw. Decide where the players start and whether the game wins when they meet or when they each get to the other side, or come up with a different rule. (If you are unsure, just start them both at the same square and win when one gets to the end first.) Write a flow chart in gliffy to describe the game action. It should have a win boolean. Keep going until win = true and set win = true based upon your game. It should alternate between players, so use a turn variable that will toggle between 0 for the first player and 1 for the second player.