Java assignment 3 - Assignment description Language Java Level Advanced Price 80$ Programming Assignment You are going to design and implement the

Java assignment 3 - Assignment description Language Java...

This preview shows page 1 - 3 out of 11 pages.

Assignment description. Language : Java. Level : Advanced. Price : 80$ Programming Assignment. You are going to design and implement the classes that will be used in an application that plays a game of Blackjack. You will develop four classes: A Card class that represents a standard playing card. Each card has a suit and a face value. The Card class should implement the Comparable interface. A DeckOfCards class that stores 52 objects of the Card class. The methods should include the ability to shuffle the deck, deal a card, and report the number of cards left in the deck. The program must keep track of the cards previously dealt and not deal the same card twice unless the deck is reshuffled. A BlackJack class that represents the play of the game, with a single player that plays against the “house”. The game is initialized and continues play until the user decides to quit. The program should keep track of the number of hands won and lost by the player. Cards are dealt to both the player and the “house”. The player decides whether or not to receive another card (a “hit”), with a goal of 21. The “house” must stand on 17, anything below that requires another card dealt. A driver program to create the BlackJack class and play until the user quits. Once you have completed the black jack game, using the Comparable interface that you've implemented, sort the remaining cards in the deck and print out the deck. You may use either insertion sort or selection sort. You will need to create all of the documentation for each of the new classes (description of classes and their members and algorithms for any non-trivial methods). You should also create the program documentation (description, inputs / outputs, assumptions, algorithm , test cases). Your program should be neat, easy to read, correctly indented, with appropriate comments.
Image of page 1
Solution. BlackJack.java import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; public class BlackJack { private DeckOfCards deck = new DeckOfCards(); private int allHandsCount; private int wonHandsCount; private int loseHandsCount; public Card[] playerCards = new Card[ DeckOfCards.CARDS_IN_DECK ]; public int playerCardsCount; public Card[] dealerCards = new Card[ DeckOfCards.CARDS_IN_DECK ];
Image of page 2
Image of page 3

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture