- Overview
This assignment aims to establish a basic familiarity with the JDK development system and its associated on-line Java API class documentation. Students should apply the appropriate fundamental programming concepts (such as variables, constants, arrays, strings, methods, selection and repetition constructs etc.) and make use of appropriate Java API classes (such as Scanner, PrintWriter, String etc.) that they have learnt to solve the given problem.
- Objectives
On completion of this assignment a student should be able to write simple Java application
that:
- Makes use of selection and repetition constructs to achieve desired outcomes
- Stores data to and reads data from arrays
- Generates output to and reads input from the console window
- Reads data from and writes data to text file
- Manipulates string using Java API String class
- handles basic errors
- Applies object-oriented concepts
- Scope
This assignment is based on individual effort. You are required to design, develop and test a one player Java game application named HighLow Sum.
Besides providing the required functionalities, your program should incorporate appropriate error handling. Comments are also to be inserted to improve program clarity. Before you start coding your program, you are strongly advised to carry out proper problem analysis and program design. You are required to use JDK 1.5 developer version or later.
- Requirements
4.1 Background
HighSum is a turned based community card game that can be played with two to five 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.
The game uses a standard deck of 52 French playing cards.
A standard deck of 52 French cards consist of four suite; clubs (♣), diamonds (♦), hearts (♥) and spades (♠). Each suite consists of 13 cards with the following symbol; A,2,3,4,5,6,7,8,9,10,J,Q, K.
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 red cards (hearts and diamonds) 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 black cards (spades and clubs) are valued as follows:
- Cards from 1 (Ace) through 9 are valued at negative of 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 7.
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.
The player with the highest second card surface value will make a call by stating the amount to bet. The other player will need to place the same amount of bet.
If two cards have the same surface value, use suits ranking to break the tie.
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 card surface value 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.
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 value wins the game.
The winner gets all the bet on the table.
If two players get the same highest accumulate value, the bet on the table is shared by both players.
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.
4.2 Minimum required Functionalities
Develop a Java program for the two-players HighLow Sum game described above.
The game starts by the player logging into the game. The players data (login in, SHA-256 password, last login date and score) are stored in players.dat file from assignment 1.
(The texts in bold are data input by the player)
HIGHLOW SUM GAME LOGIN
Enter Login name> IcePeak
Enter Password > password
Upon logging in, the player will enter the game.
(Below is a sample output of one game play)
HIGHLOW SUM GAME
================================================================================
IcePeak, You have 100 chips
Game starts Dealer shuffles deck.
Dealer dealing cards ROUND 1
Dealer
<HIDDEN CARD> <Club 6 (-6)>
Partial Value: -6
IcePeak
<Diamond Ace(+1)> <Spade 6(-6)>
Value:-5
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 (-6)> <Diamond 9 (+9)>
Partial Value: 3
IcePeak
<Diamond Ace(+1)> <Spade 6(-6)> <Heart 7(+7)>
Value:2
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 (-6)> <Diamond 9 (+9)> <Heart Ace (+1)>
Partial Value: 4
IcePeak
<Diamond Ace(+1)> <Spade 6(-6)> <Heart 7(+7)> <Spade 9 (-9)>
Value:-7
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 (-6)> <Diamond 9 (+9)> <Heart Ace (+1)> <Spade 2 (-2)>
Partial Value: 2
IcePeak
<Diamond Ace(+1)> <Spade 6(-6)> <Heart 7(+7)> <Spade 9 (-9)> <Heart King (+10)>
Value : 3
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 (-1)> <Club 6 (-6)> <Diamond 9 (+9)> <Heart Ace (+1)> <Spade 2 (-2)>
Value: 1
IcePeak
<Diamond Ace> <Spade 6> <Heart 7> <Spade 9> <Heart King>
Value : 3
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.
Updates of players score
After each game, the program should update the score for that player in the players.dat text file immediately.
For example if IcePeak old chip is 100 and IcePeak wins the current game, the file should be updated to:
For example
BlackRanger|21a57f2fe765e1ae4a8bf15d73fc1bf2a533f547f2343d12a499d45643453ad4|10|Jason Tan|[email protected]|2000-1-18BlueKnight|e765e4456e4f1ae4ae8bf15d73f435535e4a56f441f2556315a23646473e3454|15|Mary Tey|[email protected]|1999-2-22IcePeak|343a4d56b453c76e5e1ae54a8bf15d73fc1bf2a533f547f2343d19c0592044d4|140|Peter Loh|[email protected]|1998-1-9GoldDigger|bf2a536446464643e32335b3eddff2233433f547f2343d12a49343345ab53c4d|22|Zack Toh|[email protected]|2001-3-8 |
Error Handling
Your program should be able to handle error situations like where a player enter wrong password. You should look out for other possible exceptions and handle them too.
- Submission
A complete submission requires the following items:
- Report
- Program in Zip file for execution (see below)
- Merge all your class codes (exclude the Utility, Keyboard, Card and Deck class) into a single txt file for turnitin submission. (see below)
Zip file instruction
Go to the Eclipse workspace folder, locate your project folder and then the src folder.
Copy all the dat files into the src folder (or the appropriate subfolders).
Make sure that you are able to compile and run your program using the command (javac GameModule.java and java GameModule) directly from the command prompt from the project src folder.
Rename the project src folder using your UoW student number.
Zip up the folder for submission.
As I might be running and testing your codes from my laptop, it is very crucial that you follow the above instruction for submission.
Merge all java class codes using SignAllFiles
Download SignAllFiles.class from Moodle.
Copy SignAllFiles.class into the project folder.
Remove the common Utility,Keyboard, Card and Deck class from the project folder.
From the command line, change directory to the project folder.
Run java SignAllFiles
A txt file with the all the java codes name will be generated.
The text file is named with a hash value (digital signature).
Do not rename the file, the digital signature is a prove that the codes you submit in the zip file and the codes for turnitin check is exactly the same.
Submit that generated txt file to Moodle for turnitin check.
Note: You need to ensure that the files you have submitted in the zip files and the merged files (with digital signature) are exactly the same.
Missing in any of the above items is consider non-submission.
Late submission for any above items is consider late submission.
Program file header
For each Java program file, provide the header as shown
/*
* CSCI213 Assignment 2
*
* File name: (state name of .java file)
* Author: (State student name in FULL)
* Student Number: (State UOW student number)
* Description: (A brief description of this class)
*/
Any late submission of work must be accompanied by an application for Special Consideration, requested via SOLS. Unless an extension is granted, any late submission will receive a penalty of 25% of its total worth per day including weekends, and will result in zero mark being recorded on or after the 3rd late day. Request for extension with supporting document must be submitted to SIM administration for further consideration before the submission date and the tutor must be informed. Extension will be granted on a case-by-case basis.
Report requirements
The report to be submitted consists of the following sections:
- Cover page clearly state your name and UOW students number.
- Content Page
- UML class design
- Test-run of Program: You have to provide screen outputs to show the correct execution of your program according to the requirements stated.
- Error Handling: List down and explain the errors and exceptions that your program can handle. Provide screen captures here.
- Enhancements: List down and explain all the enhancements that your have done. Provide screen captures here
- Conclusion and Reflection
Testing requirements
Make sure that you are able to compile and run your program using the command (javac GameModule.java and java GameModule) directly from the command prompt from the project src folder.
In the players.dat, you should have the following FOUR players data.
Login Name | Password | Chips | Name | E mail | Birthdate |
p1 | p1 | 10 | Player 1 | [email protected] | 2000-1-11 |
p2 | p2 | 12 | Player 2 | [email protected] | 2001-12-2 |
p3 | p3 | 15 | Player 3 | [email protected] | 1999-2-7 |
p4 | p4 | 9 | Player 4 | [email protected] | 1998-3-15 |
Refer to Report guideline and marks allocation document for detailed report requirements.
Reviews
There are no reviews yet.