Pledged Lab QuizThis lab quiz is pledged. You may use the course textbook, and NOTHING ELSE. This means you cannot use any files in your home directory, previous assignments, slides, etc. However, you should still save your file into your home directory. You have 1 hour and 15 minutes to complete this lab quiz. You will need to submit a single file called LabQuiz1.java. You may download the skeleton code here: LabQuiz1.java. You must also save the Deck.class file to the same directory that your LabQuiz1.java file is in. For both files, right click on the link and select "Save as" (or "Save target as"). The TAs cannot help you with Java-related issues on this quiz. If you are having problems getting JCreator to work, can't log in to the machines, etc., then you are welcome to ask the TAs for assistance. If you do not understand what the lab is asking, the TAs may be able to help you (meaning if it's a problem with our explanation, then they can help you -- if you've been skipping the lectures so far and have no idea what any of this means, you are on your own). If you get an error in JCreator that states, "cannot find symbol class Deck", then you have not saved the Deck.class file properly. You may ask a TA to help fix this problem. In other words, if you can't get the skeleton code to compile, then you can ask for help. Once you make any modifications to the skeleton code, you cannot ask for help. Advice
PurposeIn this lab quiz, you will finish the development of a new and very exciting card came. In this game, 5 cards are drawn from a deck, and their face values are totaled. If the value is greater than 36, then you win. If the value is less than or equal to 36, then you lose. A pretty simple game, but we are sure it will soon replace Texas Hold'em as the popular card game of choice. BackgroundA standard deck of cards has 52 cards, the cards are split evenly into four suits: spades (♠), hearts (♥), diamonds (♦) and clubs (♣). Note that two of the suits are colored red (hearts and diamonds) and two are colored black (spades and clubs). The Deck we use will be abbreviating the suits by their first letter: "S", "H", "D", and "C", respectively. Each suit has 13 "ranks," with point values 1 through 13. The point value-to-rank correspondence is as follows: 1 is called an Ace, 2 through 10 are the corresponding rank of the same name, 11 is called a Jack, 12 is a Queen, and 13 is a King. If you are confused about how a standard deck of cards works, you may ask a TA for help. But not how the Deck class (described below) works. Deck ClassFor this quiz, you will need to use the Deck class, which we describe below. For our purposes, each card in the Deck will be identified by integer values from 1-52. For example, the int value of 1 is an Ace of clubs; 13 is a King of clubs; 14 is an Ace of diamonds, 26 is a King of diamonds, etc. You don't have to remember which is which, though, as there are methods (getCardName() and getValue()) which will do that for you. The relevant methods in the Deck class are as follows.
Lab QuizTo get full credit on this quiz, your code must complete the following ten steps. These steps are included in the skeleton code as comments (and some are already completed).
Although this may seem like a lot of steps, note that steps 1 and 2 are already done for you in the skeleton code. And steps 3, 5, and 7 are the same thing. Thus, there are really 6 steps that need completing. For testing your code, you should hand calculate the point total of the hand dealt and compare it to the value printed (you do not need to include proof of testing for lab quizzes). Get the steps working in order! Make sure step 1 works before you move onto step 2. If you don't follow this, you will end up with a mess of code that doesn't work, and you will not be able to fix it within the lab quiz time. There will be partial credit given for this lab quiz -- so if you only get steps 1-6 working, you will get a good amount of points. But if you have a large mess of code that doesn't work, you will get very few points. Sample outputBelow is a sample run of the program. Note that the numbers in parentheses are indicating which of the 10 steps are being performed -- this is just for your aid in reading the sample output. You don't have to include the numbers in your program (although you are welcome to, if you want). Note that no user input is required for this program. Your output should give the same information, but does not have to be formatted the same. (1) Welcome to the CS 101 Card Game! (2) Creating variables... (3) The deck is size 52 and is: [ AC, 2C, 3C, 4C, 5C, 6C, 7C, 8C, 9C, 10C, JC, QC, KC, AD, 2D, 3D, 4D, 5D, 6D, 7D, 8D, 9D, 10D, JD, QD, KD, AH, 2H, 3H, 4H, 5H, 6H, 7H, 8H, 9H, 10H, JH, QH, KH, AS, 2S, 3S, 4S, 5S, 6S, 7S, 8S, 9S, 10S, JS, QS, KS ] (4) Shuffling the deck... (5) The deck is size 52 and is: [ 7D, JD, QH, 2H, 3C, 10H, 6D, 4D, JH, 7C, 3H, 2D, AS, 7S, JC, 8C, 6H, KD, QS, 3S, 9C, 8D, KC, 6C, 2C, 4C, AC, 5S, JS, 9S, 5D, 6S, 4S, AH, 10D, KS, 5H, 4H, 3D, AD, QD, 8H, 9H, QC, 10C, KH, 5C, 2S, 10S, 7H, 9D, 8S ] (6) Dealing 5 cards: Card 1: 7D Card 2: JD Card 3: QH Card 4: 2H Card 5: 3C (7) The deck is size 47 and is: [ 10H, 6D, 4D, JH, 7C, 3H, 2D, AS, 7S, JC, 8C, 6H, KD, QS, 3S, 9C, 8D, KC, 6C, 2C, 4C, AC, 5S, JS, 9S, 5D, 6S, 4S, AH, 10D, KS, 5H, 4H, 3D, AD, QD, 8H, 9H, QC, 10C, KH, 5C, 2S, 10S, 7H, 9D, 8S ] (8) Summing the card values... (9) The value of your hand is: 35 (10) Sorry, that value does not beat 36, please play again!
If the sum of the dealt cards was greater than 36, the last two steps would look like the following (of course, the shuffled deck in steps 5 and 7, and the dealt cards in step 6 would be different): (9) The value of your hand is: 51 (10) Congratulations! Your hand value: 51 beats 36 Incremental development
Other RequirementsYou are only required to follow a few of the good programming practices discussed in HW 1. If you have time, feel free to do the others -- but due to the time constraints of the quiz, you don't have to do them all. The ones you must do are listed below.
SubmissionWhen you are finished, submit your LabQuiz1.java file. You will have to "sign" a pledge on the submission.
|