1 objectives on completion of this assignment a student should be able
Search for question
Question
1. Objectives
On completion of this assignment a student should be able to write a Java application that:
• Makes use of selection and repetition constructs to achieve desired outcomes
• Stores data to and reads data from ArrayList
• Generates output to and reads input from the console window
• Know how to use various standard Java classes (e.g. String class)
• Handles basic errors and exceptions
• Know how to apply and design a program using object-oriented concepts
2. Background
HighSum is a community card game that can be played with 2 to 10 players.
One of the players will be the dealer.
In this assignment, there is only 1 dealer, that is the Java program, and a single human player.
Since the dealer is "a type" of player, references to "player" may be to the dealer or the single human
player.
Values of Cards
The game uses one or more decks of the standard playing cards.
The suits are ranked as below
•
spades (highest).
•
hearts,
clubs,
diamonds (lowest)
The cards are valued as follows:
Cards from 1 (Ace) through 9 are valued at their face value.
•
The 10, Jack, Queen, and King are all valued at 10.
The value on a player hand is the sum of the point counts of each card in the hand. For
example, a hand containing (4,6,9) has the value of 19.
University of Wollongong, 20
Game Procedure
Game Start
The game starts with the dealer shuffles the deck of cards.
The dealer will deal (distribute) the cards to the players.
The dealer make two passes so that the players and the dealer have two cards each.
Two passes means that the dealer must distribute the cards in such a way that, the first card belongs
to the player, the second card belongs to the dealer, the third card belongs to the player and the
fourth card belows to the dealer.
Round 1
The first card of the dealer and player are both hidden, that is face down. The
dealer and player can view their own hidden first card.
The second card is visible to both the dealer and player.
Copyright SCIT
23
Page 1 The player with the highest second visible card will make a "call" by stating the amount to bet.
The other player will need to place the same amount of bet.
Both the bet amount from dealer and player will be placed on the table. The
dealer is not allowed to quit the game.
Round 2
The dealer make one pass.
Dealer and player each have 3 cards now.
The player with the highest third visible card will make a "call" by stating the amount to bet.
The other player will need to place the same amount of bet or choose to quit the current game.
Dearler is not allowed to quit the game.
If the human player choose to quit at this round, all the chips on the table belongs to the dealer
and the current game ends here.
Both the bet amount from dealer and player will be placed on the table. The
dealer is not allowed to quit the game.
Round 3
Similar to round 2.
Round 4
Similar to round 2 plus the following rule:
Each player compares the values of cards hold by other players at the end of each game to
determine the winner. The player with the highest accumulate values win the game. The
winner gets all the bet on the table.
Next Game
All the cards on the table are shuffled and placed at the end of the deck. The
game will start again unless the player choose to leave the game.
Please note that the above game description is a simplified version of the real game and there are
also many different versions in different countries. The specifications given in this document are
more than sufficient for you to complete this assignment. If you have doubts on the game logic,
please feel free to clarify with your tutor. Do take note that the emphasis of this assignment
is to implement the game logic using Object-oriented programming.
3. Task
Develop a Java program for the HighSum game described above.
Game Play Module
The game starts by the player logging into the game.
(The texts in bold are data input by the player)
HighSum GAME
Enter Login name> IcePeak
Enter Password > password
Copyright SCIT, University of Wollongong, 2023
Page
2 Upon logging in, the player will enter the game.
(Below is a sample output of one game play)
HighSum GAME
IcePeak, You have 100 chips
Game starts Dealer shuffles deck.
Dealer dealing cards ROUND 1
Dealer
<HIDDEN CARD> <Club 6>
IcePeak
<Diamond Ace> <Spade 6>
Value: 7
Player call, state bet: 10
IcePeak, You are left with 90 chips
Bet on table : 20
Dealer dealing cards ROUND 2
Dealer
<HIDDEN CARD> <Club 6> <Diamond 9>
IcePeak
<Diamond Ace> <Spade 6> <Heart 7>
Value:14
Dealer call, state bet: 10
Do you want to follow? [Y/N]: Y
IcePeak, You are left with 80 chips
Bet on table : 40
Dealer dealing cards ROUND 3
Dealer
<HIDDEN CARD> <Club 6> <Diamond 9> <Heart Ace>
IcePeak
<Diamond Ace> <Spade 6> <Heart 7> <Spade 9> Value:23
Page
3
Copyright SCIT, University of Wollongong, 2023 Do you want to [C] all or [Q] uit?: C
Player call, state bet: 10
You are left with 70 chips.
Bet on table : 60
Dealer dealing cards ROUND 4
Dealer
<HIDDEN CARD> <Club 6> <Diamond 9> <Heart Ace> <Spade 2>
IcePeak
<Diamond Ace> <Spade 6> <Heart 7> <Spade 9> <Heart King>
Value
: 33
Do you want to [C] all or [Q] uit?: C
Player call, state bet: 10
You are left with 60 chips
Bet on table : 80
Game End Dealer reveal hidden cards
Dealer
<Spade Ace> <Club 6> <Diamond 9> <Heart Ace> <Spade 2>
Value
: 19
IcePeak
<Diamond Ace> <Spade 6> <Heart 7> <Spade 9> <Heart King>
Value
: 33
IcePeak Wins
IcePeak, You have 140 chips
Dealer shuffles used cards and place behind the deck.
Next Game? (Y/N) > Y
And the game continues until the player exits the game.
Error Handling
Your program should be able to handle error situations like where a player enter wrong password or
has insufficient chips.
You should look out for other possible exceptions and handle them too.
Game Data
All required data (e.g. player login name, passwords and chips) maybe hardcoded.
4. Submission
Page
4
Copyright SCIT, University of Wollongong, 2023 A complete submission requires the following items:
a. Report
b. Java codes
Compress the above into a zip file and upload to Moodle. (DO NOT embed the zip file into the
report word document)
Report
The report to be submitted consists of the following sections:
1. Classes design:
Draw all the Class diagram (UML standards) with the class name, attributes and methods
clearly stated.
2. Test-run of Program:
You have to provide screen outputs (similar to those shown in Section 3 Task Game Play
Module) to show the correct execution of your program according to the requirements stated.
The required test runs are: Login, Dealer wins, Player wins, Player quit and Tie.
3. Error Handling:
List down the errors and exceptions that your program can handle. Provide screen captures
here. (There should be at least 4 error cases. Work out those error cases yourself.)
4. Any Other Comments:
State any other comments here, including any points to take note of if the tutor is to test run
the program.
Page
5
Copyright SCIT, University of Wollongong, 2023