Consider the game of Monopoly. The game consists of a sequential set of 40 squares containing 28 properties, 6 Action squares (3 "Chance", 3 "Community Chest"), 2 Tax squares, "GO", "Jail", "Free Parking", and "Go To Jail.". The game is played by moving through the set of squares. Every time a player lands of a square, they take a different action, depending on the type of a square. For example, if you land on a "Tax Square", you must pay the bank a certain amount of money, but if you land on an "Action Square" you must draw a card from the appropriate pile and follow the instructions on the card.
Note that this is a perfect example of polymorphism. Take a deep breath and relax, you are not implementing Monopoly during this lab. However, you are going to use polymorphism to describe the gameplay. To accomplish this you should:
public abstract String
landOn()
.landOn
method. Each of the
derived classes should return a string that describes what the
player can do if they land on that square.The file DrawCards.java contains a programs that draws a list of cards. It uses the classes Card.java to represent individual cards and ArrayList.java to represent a list of cards. The ArrayList class add generics and a few unimplemented methods to the ArrayList class you created in for the last assignment. It also uses the images in GPLCards.zip (extract the directory in the tar file and place it in your lab directory). Try running the program. Notice that the two buttons do not do anything. Fix that by doing the following.
compareTo
method. Look at the javadoc for this method to figure out how
you can use it to find the minimum in an array. Also note that
in order to call the compareTo
method on an object
of type T, the object must be cast to type
Comparable<T>.CompareTo
method. Note, it is easy to decide
whether a two of clubs is less than or greater than a three of
clubs, but what about a two of clubs and a two of spades? It is
up to you to decide what the compareTo
method should return in cases like this.Submit a zip file of your code on the course Inquire site that uses your last names as the file name.