这是小弟本学期的一份作业,低估这份东西难度了,现在还剩5天时间实在来不及搞,谁知道哪里有源代码下载可以让我参考参考的,不胜感激。如果有强人能帮忙写一份的更好了,价格好说,工行网银转账或者支付宝。有兴趣的请个联系方式,谢谢。我的邮箱: [email protected]开发环境BlueJ,下面附上要求: 2. Specification
Write a system that plays one or more games of Blackjack. The rules of the game are listed in Appendix A. Each player starts with $100.00, and the dealer (the bank) starts with $1000. The sequence of events is:
1. Ask for the number of players (between 1 and 8), and the name of each player.
The number does not include the dealer, and the dealer has no name.
2. Each player and the dealer gets one card.
3. Each player bets some amount.
4. Each player and the dealer gets one card.
5. Each player in turn plays his or her hand.
A player can actually have several hands, if there is s split.
6. The dealer plays his or her hand.
7. Money is paid, then the player stakes and the bank amount are shown.
8. The system asks if you want to play another game, and acts accordingly. 2.1 Cards and deck order
A card is shown in the form <value><suit>. 
A value is A (Ace), 2-10, and then J, Q, K. 
A suit is shown as a single character: H, D, C, or S. Create the deck with all four Aces first, then all twos, and so on up to the four kings. Use the suit order Heart, Diamond, Club, Spade. 2.2 Data structures
Use a LinkedList to store the deck and the hands. Do not use arrays, arrayLists, or any other data structure except LinkedList to store multiple objects. 2.3 User input
Your system should accept upper or lower case input. 2.4 Simplifying assumptions
To make the assignment easier
• assume that all inputs are correct and valid; do not validate the input
• don't run out of money; choose the bet values so this never occurs
• don't run out of cards; stop playing before the deck is all used 3. Sample transcripts
The system reads from and writes to the console window. Six runs of my system are shown in Appendix B. Your transcript of the normal case should be as close as possible to the input and output shown for the normal case, except for variations in the player names, the card order and the player and dealer choices. Your other transcripts should be identical to those shown here. The input of the number of players and the player names is shown only for the first sample transcript, to save paper. A player sees the hand and the hand value before each request for the player's action. The hand value is calculated using a value of 1 for an Ace, so the displayed value may not actually be the value used by a player. Note that the prompt for the dealer is different to the prompt for a player; a player can draw, buy, or sit but a dealer can only draw or sit. Note that my system accepts either upper or lower case input, and your system should do the same. I have shown the label in the sample transcripts in bold Times font to reinforce the fact that the labels are added by hand, after the system IO has been stored in the text file. The actual system IO is then shown in Courier font.
4. Your transcripts
Save each run of your system to a text file; you may need to copy and paste the console window several times to get a complete run, due to the limited size of the console window. Label each run as described below: edit the file to add a single line at the top, followed by a space line. The first line in each of your ioN.txt files should start with the words "This run". Show that your system works for the normal cases: sit, player busted, and dealer busted. Then show that your system works for each type of special hand; you will need to use different decks to show that the special cases work as specified. Store each run to a separate text file, label each run, and then merge the text files to get the final transcript to hand in. 4.1 Normal games
Create a normal deck and shuffle it. Play two games with three players to show that your system handles all the normal situations. My run for two games with three players is shown in Appendix B; in the first game the dealer sits, and in the second game the dealer busts. Your transcript in the file io1.txt should be similar to this, but not identical. The players' names, the cards, the player choices, and the bets can all vary from those shown in my transcript. Your runs should show the following situations:
• a player draws
• a player buys
• a player sits
• a player goes bust
• the dealer does not go bust
• the dealer goes bust
• the stake and bank amounts are correct within a game
• the stake and bank amounts are correct over multiple games

4.2. n and under
Create a normal deck and don't shuffle it. Play one game with two players. Player 1 gets a hand of eight and under, and player 2 gets a hand of six and under. Your transcript in the file io2.txt should be identical to this run, except the player names can vary. 4.3 6-7-8
Create a deck with the cards from 6 to King; that is, a deck of 32 cards; don't shuffle it. Play one game with three players. All players get the special hand of 6-7-8. Your transcript in the file io3.txt should be identical to this run, except the player names can vary. 4.4 7-7-7
Create a deck composed of 8 sevens; don't shuffle it. Play one game with three players. All players get the special hand of 7-7-7. Your transcript in io4.txt should be identical to this run, except the player names can vary. 4.5 Dealer gets BlackJack
Create a deck of four Aces and four Kings; don't shuffle it. Play one game with two players. Your transcript in io5.txt should be identical to this run, except for the player names. 4.6 Player gets Blackjack
Create a deck of six cards, in the order 10, K, 10, A, A, A. Don't shuffle it. Play one game with two players. Player 1 will get a hand worth 21, player 2 will get a BlackJack, and the dealer will get a hand worth 21. Your transcript in io6.txt should be identical to this, but for the names. 4.7 Split
Show that your system handles splitting, up to a split into four hands. No transcript has been provided for this task. The format in the console window is left up to you, except that it should be clear, easy to use, and consistent with the rest of the system. The testing is left up to you. Note that my system uses 'S' as the player choice for sit, so you can't use 'S' to indicate a choice to split. Store your transcript in the file io7.txt. 5. class In
Download the class In from Assignments/1. Console IO does not quite work properly on my terminal, so I wrote a class that reads a string and converts it to a character, integer, or double as needed. Include this class in your BlueJ project, and use it as described in Appendix C.
6. What to hand in
Hand in the normal version of your code; that is, a normal deck that is shuffled. Hand in a listing of the Java files that you write. Start each listing on a new page. Combine all the labelled transcripts in the order given in Section 4 into one file named io.txt, and hand in that file. 7. Expected work load
This assignment has been allocated a load of 25 hours for the average student. Write the time that you actually spent on the assignment on the assignment header page, as described in Section 9. To give you some idea of the code involved, my solution has about 350 lines of code without the High Distinction task (the split) and class In. 7.1 How to save time
One simple way to save time while you are building the system is to avoid unnecessary IO. The complete system reads in the number of players, the player names, and the amount of each bet. However, you do not have to do this every time you run your code. Omit these inputs in the development versions; that is
• set the number of players to 2
• don't mention the player names
• set every bet to $1
Make sure you get rid of these hacks in the final system!

解决方案 »

  1.   

    9. Assignment submission and return 9.1 Hard copy
    Place your folder in the labelled box (box 21) near the Student Centre on level 2 of Building 10 before 5:00 pm on the due date. The folder should contain:
    1. A header page that shows at the top
    • your name and student id
    This is the last name (in Western countries the family name) shown on your UTS student card. I will use the last name as an index to store your  in my spreadsheet. 
    • your tutorial number and tutor's name
    • the number of hours you spent on this assignment. 2. A printout of your class listings; a class listing shows (lists) the code in the class. Start each class on a new page. Place the class listings in client and then inheritance order as described in Appendix D; client order reflects the calling order, so this makes the code easier to trace. Only list the classes that you write. Do not list any enumerated types or the class In.3. A transcript of your system's IO in Courier font, as described in Section 4 and illustrated in Appendix B. Each run has a preceding label of the form "This run ...". Just hand in one merged printout, from the file io.txt. If you don't show that your system works as specified, I will assume you cannot show it. Place all the hard copy in a single folder. The folder will contain first the header page, then the Java listings, then the transcripts. If you do not use a folder with a transparent front page, write your name and student id on the front of the folder. Do not put each page (or pair of pages) in its own plastic sleeve; I can't write on plastic. 9.2 Soft copy
    Send a soft copy of the class listings and transcripts as a zip file to the Digital Drop Box before 6:00 pm on the due date; the file you send is time-stamped. Directions for how to build and submit the soft copy can be seen at Assignment/1. Include all your ioN.txt files, as well as the merged file io,txt. 9.3 Assignment return
    The ed assignment will be returned in week 9, at the tutorial you nominated on the header page. Any copies not picked up at the tutorial can be picked up from the Student Centre before the end of semester. If you are charged with Academic Misconduct then I will keep the hard copy and return just the ing sheet. The ing sheet shows the  you will get if you are found to be innocent of Academic Misconduct.
    10. Late submission
    A late submission loses 20 s for each day, or part of day, late. As an example, submission of a hard copy at 5:10 on the due date loses 20 s. The assignment submission box is cleared at 5:00:01 pm each day. You may request an extension of up to five days if a problem arises (see the Subject Outline for valid reasons), but this must be arranged with the lecturer before the due date. A solution is not accepted after five days; it would get zero s.
    11. Rough ing scheme
       5 Player number and names   5 First three rounds
    20 Draw, buy, sit, bust 10 Win / lose at end of a game
    10 IO echoes sample transcript   5 Multiple games
      5 Dealer BlackJack 10 Player special hands
    10 Split 20 Good design Good design
    10 Good code style 10 Good use of inheritance Penalties
    Did not use LinkedList -100 s
    See Section 2.2
    Bad soft copy -50 s
    Not sent, not .zip, bad name
    Uneven or no indenting - 10 s 
    -1 each bad indent, maximum -10
    Unused code - 20 s 
    -2 each unused attribute or method, maximum -20
    This does not include any debugging output methods; they are fine.
    Solution does not compile maximum  is 10. Minimum essential requirements
    A pass can be obtained for a system that plays one game with no special hands. High distinction task
    All decisions about how to implement the split have been left up to you. The only constraints are that the system be easy to use, that the IO is clear and simple and consistent with the rest of the IO produced by the system.
      

  2.   

    Appendix A: Blackjack rules 
    Blackjack (also known as Pontoon and 21) has many variations; use these rules.
    1. Purpose of the game
      Blackjack is a card game in which players try to form a hand worth 21 points. The value of a hand is the sum of the card values. A player must buy or draw cards if the hand value is below 16, and busts if the hand value is over 21. At the end of the game, the dealer pays all remaining hands with a higher value than the dealer's hand.
    2. Terms
    Deck: the standard 4-suit, 52-card deck
    Hand: a hand has at least two cards
    Stake: the money owned by a player
    Bet: the money bet on a hand
    Bust: a player gives his or her cards and pot to the dealer and leaves the game
    Draw: a player receives another card
    Buy: a player pays for and receives another card
    Hit: draw or buy a card
    Sit: a player stays with the current cards (does not buy or draw)
    Split: a player splits a hand to make two hands
    Bank: The dealer is often referred to as the bank
    Royalty: A King, Queen, or Jack
    3. Number of players
    Blackjack can be played by any number of players from two upwards - it works well with 5 to 8 players - using a standard 52 card pack. The dealer is a player, but does not bet.
    4. Card values
    Royalty has a value of 10. An Ace may be high (value of 11) or low; when high, its value is 11. When low, its value is 1. A player can change the value of the Ace (from 11 to 1 or from 1 to 11) at any time. All other cards have a value equal to the face value.
    5. Order of play
    A game has four rounds.
    1. The dealer deals one card face down to each player, starting with the player to the dealer's left, going round the table and ending with the dealer.
    2. Starting again with the player to the dealer's left and going around clockwise, the players other than the dealer place their initial bets in front of them.
    3. The dealer now deals a second card face down to each player, and all the players look at their two cards. If the dealer has a Blackjack this is immediately shown, and the banker collects double the stake from each player.
    4. Each player in turn plays the hand, as described below.
    4. Player's turn
    When it is your turn, you have the following possibilities: Declare a Blacjack
    If your two cards are an ace and a royalty card, you declare it by showing them face up. Split
    If your two cards have the same face value, you may split them into two hands by putting them face up on the table and placing another bet equal to your initial bet. The banker immediately deals another card face down to each of your hands, and you then play the hands one at a time, as separate hands with separate stakes. If either of the new cards dealt is equal to the first two you may choose to split again, creating three or even (theoretically) four separate hands, each with its own stake. Note that you cannot split two ten point cards unless they are actually equal - two queens can be split but a queen and a jack cannot.  Buy a card
    If the total value of your cards is less than 21, you can buy another card. You increase your bet by some amount, and the dealer deals you another card face down. If your total is still less than 21 you may buy another card. You can keep buying cards until you sit or bust. Draw
    If the total value of your cards is less than 21 you can draw another card. Your stake is unaffected, and the dealer deals you one card face up to add to your hand. You can keep drawing cards until you sit or bust. Once you have drawn, you can no longer buy. Sit
    If the total value of your cards is between 16 and 21 (inclusive) then you can sit. You stay with the cards you have, your stake stays as it is and it is the next hand's turn to play. Bust
    If a new card causes the total value of your hand to be more than 21 you are bust; you throw in your hand face up, and the dealer takes your stake.
    5. Dealer's turn
    If all the (other) players have gone bust, then the game is over. If at least one (other) player is left in the game, then the dealer's two cards are turned face up and cards are added until the dealer sits or busts. Like the other players, the dealer cannot sit on a hand worth less than 16. If the dealer goes bust, then all (the other remaining) players are paid. If the dealer does not go bust, then all (the other remaining) players with a better hand are paid as described below. The dealer has the house advantage; the dealer wins if the player and dealer hands have the same value. Remember that a dealer's Blackjack terminates the game at the end of round three.
    6. Special player hands
    The following hands are paid more than the bet. They are always paid no matter what the dealer has in his or her hand, unless the dealer had a Blackjack (when no player wins).
    • a BlackJack is paid twice the bet
    • six, seven, eight is paid twice the bet
    • three sevens is paid three times the bet
    • five and under (a valid hand with five cards) is paid four times
    • six and under is paid five times
    • seven and under is paid six times
    • eight and under is paid seven times
    • nine and under is paid eight times
    • ten and under is paid nine times
      

  3.   

    Appendix B: System transcriptsThis run shows the normal situations from the file io1.txt.How many players (1-8)? 3
      Name of player 1: Fred
      Name of player 2: Mary
      Name of player 3: Doan
    Player 1 Fred has 10D  10
        Amount to bet: $10
    Player 2 Mary has 2S  2
        Amount to bet: $20
    Player 3 Doan has KD  10
        Amount to bet: $30Player 1 Fred
      10D 7C  17| Enter action(B/D/S): s
    Player 2 Mary
      2S 8H  10| Enter action(B/D/S): b
        Amount to bet: $40
      2S 8H 2H  12| Enter action(B/D/S): d
      2S 8H 2H 4C  16| Enter action(B/D/S): s
    Player 3 Doan
      KD 2D  12| Enter action(B/D/S): d
      KD 2D 10C  22| Bust!
    Dealer
      3D QH  13| Enter action(D/S): d
      3D QH JS  23| Bust!End of game
      Player 1 Fred wins $10.00
      Player 2 Mary wins $60.00    Player 1 Fred has $110.00
        Player 2 Mary has $160.00
        Player 3 Doan has $70.00
        Dealer has $960.00Another game? (Y/N) yPlayer 1 Fred has KS  10
        Amount to bet: $20
    Player 2 Mary has AH  1
        Amount to bet: $80
    Player 3 Doan has 8S  8
        Amount to bet: $2Player 1 Fred
      KS 2C  12| Enter action(B/D/S): b
        Amount to bet: $5
      KS 2C 6C  18| Enter action(B/D/S): s
    Player 2 Mary
      AH 9D  10| Enter action(B/D/S): b
        Amount to bet: $10
      AH 9D AC  11| Enter action(B/D/S): b
        Amount to bet: $20
      AH 9D AC 7H  18| Enter action(B/D/S): s
    Player 3 Doan
      8S 6H  14| Enter action(B/D/S): d
      8S 6H 5H  19| Enter action(B/D/S): s
    Dealer
      QC 10S  20| Enter action(D/S): sEnd of game
      Player 1 Fred loses $25.00
      Player 2 Mary loses $110.00
      Player 3 Doan loses $2.00    Player 1 Fred has $85.00
        Player 2 Mary has $50.00
        Player 3 Doan has $68.00
        Dealer has $1097.00Another game? (Y/N) nThis run shows the n and under situations from the file io2.txt.Player 1 Fred has AH  1
        Amount to bet: $1
    Player 2 Doan has AD  1
        Amount to bet: $1Player 1 Fred
      AH AS  2| Enter action(B/D/S): b
        Amount to bet: $1
      AH AS 2C  4| Enter action(B/D/S): b
        Amount to bet: $1
      AH AS 2C 2S  6| Enter action(B/D/S): b
        Amount to bet: $1
      AH AS 2C 2S 3H  9| Enter action(B/D/S): b
        Amount to bet: $1
      AH AS 2C 2S 3H 3D  12| Enter action(B/D/S): b
        Amount to bet: $1
      AH AS 2C 2S 3H 3D 3C  15| Enter action(B/D/S): b
        Amount to bet: $1
      AH AS 2C 2S 3H 3D 3C 3S  18| Enter action(B/D/S): s
    Player 2 Doan
      AD 2H  3| Enter action(B/D/S): b
        Amount to bet: $1
      AD 2H 4H  7| Enter action(B/D/S): b
        Amount to bet: $1
      AD 2H 4H 4D  11| Enter action(B/D/S): b
        Amount to bet: $1
      AD 2H 4H 4D 4C  15| Enter action(B/D/S): b
        Amount to bet: $1
      AD 2H 4H 4D 4C 4S  19| Enter action(B/D/S): s
    Dealer
      AC 2D  3| Enter action(D/S): d
      AC 2D 5H  8| Enter action(D/S): d
      AC 2D 5H 5D  13| Enter action(D/S): d
      AC 2D 5H 5D 5C  18| Enter action(D/S): sEnd of game
      Player 1 Fred wins $49.00
      Player 2 Doan wins $25.00    Player 1 Fred has $149.00
        Player 2 Doan has $125.00
        Dealer has $926.00This run shows 6-7-8 hands from the file io3.txt.Player 1 Fred has 6H  6
        Amount to bet: $1
    Player 2 Doan has 6D  6
        Amount to bet: $1
    Player 3 Mary has 6C  6
        Amount to bet: $1Player 1 Fred
      6H 7H  13| Enter action(B/D/S): b
        Amount to bet: $1
      6H 7H 8H  21| Enter action(B/D/S): s
    Player 2 Doan
      6D 7D  13| Enter action(B/D/S): b
        Amount to bet: $1
      6D 7D 8D  21| Enter action(B/D/S): s
    Player 3 Mary
      6C 7C  13| Enter action(B/D/S): b
        Amount to bet: $1
      6C 7C 8C  21| Enter action(B/D/S): s
    Dealer
      6S 7S  13| Enter action(D/S): d
      6S 7S 8S  21| Enter action(D/S): sEnd of game
      Player 1 Fred wins $4.00
      Player 2 Doan wins $4.00
      Player 3 Mary wins $4.00    Player 1 Fred has $104.00
        Player 2 Doan has $104.00
        Player 3 Mary has $104.00
        Dealer has $988.00This run shows 7-7-7 hands from the file io4.txt.Player 1 Fred has 7H  7
        Amount to bet: $1
    Player 2 Doan has 7D  7
        Amount to bet: $1
    Player 3 Mary has 7C  7
        Amount to bet: $1Player 1 Fred
      7H 7H  14| Enter action(B/D/S): b
        Amount to bet: $1
      7H 7H 7H  21| Enter action(B/D/S): s
    Player 2 Doan
      7D 7D  14| Enter action(B/D/S): b
        Amount to bet: $1
      7D 7D 7D  21| Enter action(B/D/S): s
    Player 3 Mary
      7C 7C  14| Enter action(B/D/S): b
        Amount to bet: $1
      7C 7C 7C  21| Enter action(B/D/S): s
    Dealer
      7S 7S  14| Enter action(D/S): d
      7S 7S 7S  21| Enter action(D/S): sEnd of game
      Player 1 Fred wins $6.00
      Player 2 Doan wins $6.00
      Player 3 Mary wins $6.00    Player 1 Fred has $106.00
        Player 2 Doan has $106.00
        Player 3 Mary has $106.00
        Dealer has $982.00This run shows the dealer has Blackjack from the file io5.txt.Player 1 Fred has AH  1
        Amount to bet: $1
    Player 2 Doan has AD  1
        Amount to bet: $1
    Dealer wins with BlackJack: AC KD  11    Player 1 Fred has $99.00
        Player 2 Doan has $99.00
        Dealer has $1002.00This run shows a player with Blackjack from the file io6.txt.Player 1 Fred
      10H AH  11| Enter action(B/D/S): s
    Player 2 Doan
      KH AD  11| Enter action(B/D/S): s
    Dealer
      10D AC  11| Enter action(D/S): sEnd of game
      Player 1 Fred loses $1.00
      Player 2 Doan wins $2.00    Player 1 Fred has $99.00
        Player 2 Doan has $102.00
        Dealer has $999.00