Question: In java create a program that manages a deck of cards. The deck will be stored in a Bag which implements the Deck interface. The

In java create a program that manages a deck of cards. The deck will be stored in a Bag which implements the Deck interface.

The Card class with store:

1. A suit String

2. An int card value (0- Ace, 1,2,3, 11-Jack, 12-Queen, 13-King)

3. Constructors

4. Set/Get methods

5. toString()

6. equals()

UML Diagrams:

In java create a program that manages a deck of cards. Thedeck will be stored in a Bag which implements the Deck interface.The Card class with store: 1. A suit String 2. An int

, include the implementation of the Card, Deck and DeckInterface. Additionally DeckDriver, your Driver class will:

1. Add the following 3 cards to the deck.

1. 2 of Hearts

2. King (13) of Diamonds

3. Ace (0) of Spades

2. Output the contents of the deck from bottom to top where the first card inserted (The 2 of Hearts) is at the bottom so it is output first.

3. Remove the top card from the deck and output its value and suit using toString().

4. Output the current card at the top of the deck but do not remove it from the deck.

5. Output the contents of the deck again from bottom to top.

6. Search for the King (10) of Diamonds. Output the result of the search. Label your output.

7. Search for the Two of Hearts and output the result of the search. Label your output

8. Clear the deck

9. Output the contents of the deck.

Create an input.txt file that looks like this:

Hearts

2

Diamonds

13

Clubs

0

All output will be directed to a file called output.txt

Card -suit: String -value: int +Card() +Card(cSuit: String, cVal: int) +getSuit(): String +setSuit(cSuit: String): void +getValue(): int +setValue(cVal: int): void +toString(): String +equals(obj: Object): boolean Deck deckOfCards: TI numberOfEntries: int DEFAULT_CAPACITY: int +Deck() +Deck(aDeck: T[), num: int): void +setDeck(aDeck: T[]); void +setNumCards(num:int): void +getNumCards(): int +add(aCard: T): boolean +remove(): T +retrieve(): T +search(aCard:T): boolean +toArray(): TO +clear():void +isEmpty(): boolean Deck Interface +addCard(theCardValue: T): boolean +removeCard(theCardValue: T): T +getCard(): T +search(aCard:T): boolean +toArray(): TII +clear(): void +isEmpty(): boolean

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!