Startup.javafile you had from last lab with the one below:
This lab is the second of a multiweek sequence that will culminate in the creation of a working card game.
StackOfCards, which we will now use to
StackOfCards, but with some extra functionality. So this will be our first time for creating one class by extenidng another:
StackOfCardsin this lab.
You will need to create your own .java files for the classes that we have not provided. You will probably also need to make your own Startup.java to test your code, but you will not need to turn that file in. All grading will be done with the provided Startup.java file.
All methods below are
public. You may not add other public methods. All methods you add must be private. You are encouraged to add private methods where you see fit.
**See the JavaDoc for the same information presented differently**
Deckclass, which you must complete according to the API below. The Deck is an abstract data type, so as with StackOfCards, it can be implemented in many ways. Our implementation of the
Deckmust have the following methods:
Card peek()in StackOfCards.
Card getNthFromTop(int n)
int getSize()must be updated in this case.
void push(Card c)
pushmethod in StackOfCards. The Deck keeps track of the number of cards it contains, while StackOfCards does not. This method should appropriately adjust the value to be returned by
getSize(), as well as performing the
popmethod in StackOfCards. Look at
void push(Card c)for more detail on method function.
Card removeNthFromTop(int n)
String toString. As with
Card, for grading purposes, we will constrain your implementation of the
Deck. When the deck is constructed, the cards in it must be in the following order, from the top of the stack down: Ace of Spades, Ace of Hearts, Ace of Diamonds, Ace of Clubs, King of Spades, Hearts, Diamonds, Clubs, etc. The bottom 4 cards should be Two of Spades, Two of Hearts, Two of Diamonds, Two of Clubs.
Hand. It is the hand of cards that is actually used to play the game, and not user as a source of cards (like the
ListOfCardsthat keeps track of all the
Cardobjects currently in the hand. Here's the API for
Handwith an empty
ListOfCards. Cards in the hand are invisible (face down) by default.
DrawingPaneon which the
Card getCard(int n)
void add(Card c)
Hand. This constitutes adding both to the
ListOfCardsand to the Hand's
DrawingPane. More recently added cards go to the end of the hand.
void remove(Card c)
Card remove(int n)
void setVisible(boolean visible)
Card's visibility to the specified visibility.
DrawingPaneand empties its
Handby rank (i.e. from high to low, with Aces high). Changes in order are reflected both visually and internally.
This method is worth 5 lab points of extra credit. It is tested from Startup, so you must include at least a stub for this method if not the actual implementation.
Startupclass to demonstrate that your classes work. To ease grading, this class is provided for you. Ideally, the transcript generated by the reference implementation and your code will be identical. You should not, however, rely solely on our Startup code entirely during your own testing. After, for example, you finish the Card class, you should make completely sure that it works as expected before moving on.
Startupobject which tests the other classes in this lab.
Read the following carefully, and be sure to complete all parts below.
Handgenerated by the given