You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By card value, the suit order: Ace -> 2 -> 3 -> .... -> Jack -> Queen -> King, Clubs -> Diamonds -> Hearts -> Spades.
Reverse order of the above: King -> Queen -> Jack -> .... -> 3 -> 2 -> 1, Spades -> Hearts -> Diamonds -> Clubs.
By suit order, then suit order: Clubs -> Diamonds -> Hearts -> Spades, Ace -> 2 -> 3 -> .... -> Jack -> Queen -> King.
Reverse order of the above: Spades -> Hearts -> Diamonds -> Clubs, King -> Queen -> Jack -> .... -> 3 -> 2 -> 1.
Card Game:
Player vs Computer
Handle the interaction of the player to both select and play the game.
Ensure that the player does not 'break' the game by invalid input.
Presenting Your Project:
Overview / Introduction to set the context for the presentation.
Outline any decisions you have made about scoping / prioritisation.
Show and explain elements of your code.
Presentation / Demonstration should last no more than 20 minutes.
Everyone in the group should contribute.
Our Solution:
App:
- Instantiates welcome menu.
WelcomeSelection:
- Allows the user to choose to play snap or blackjack.
- Allows the user to see the ruled for snap/blackjack without instantiating class.
- Allows the user to sort the deck in the ways mentioned in the requirements.
- Loops infinitely until the user opts to exit.
- All choices validated and only appropriate inputs are accepted.
Welcome menu:
Sorting menu:
Input validation:
Deck
- Used by both game classes.
- Instantiates ArrayList of 52 unique cards.
- Has a method to get the next card.
- Has a method to shuffle the deck.
- Overrides toString to print out the entrie deck in order (Uses StringBuilder for memory efficiency).
- Implements the required sorting functions.
Constructor and non-sorting functions:
Sorting functions:
Card:
- Instantiates card that has private attributes of suit and face.
- Has public getters and private setters.
- Functions to convert suits/face from integers to their appropriate strings.
- Overrides toString to return full card name.
Converts card attributes to make them more readily usable in the games:
Snap:
- Uses a stack to keep track of the middle pile and compare last card.
- Adds a delay between each card being placed to make it easier to follow.
- Allows user to type to place next card so you can go at your own pace.
- Player types in 's' to snap, while the computer uses a timer to delay it's 'snap'.
- Allows the user to choose different timer speeds to allow for different reaction times.
- Ability to replay game without returning to the menu.
- All user inputs validated.
- Static rules method to allow the rules to be seen without instantiating the game class.
Gameplay example:
SnapDelayTimer:
- Used to determine how long the user has to type 's' to snap before the computer says snap.
Selection method:
BlackJack
- Hides first computer card so you don't know exactly what the opponent has.
- Allows you to twist until you are bust but not beyond that.
- Automatically assigns Aces a value of 11 and reduces the value to 1 when hand total exceeds 21.
- Computer will stop twisting at a randomised hand total between 15 (inclusive) and 19 (exclusive).
- You always lose if you bust and ties are accounted for.
- Ability to replay game without returning to the menu.
- All user inputs validated.
- Static rules method to allow the rules to be seen without instantiating the game class.
Gameplay example:
Randomised computer stick point and Reducing ace value when bust:
Testing:
- Added testing where appropriate.
- Tested a range of expected and unexpected inputs.
- All unit tests passed.
Test code:
About
We have spent two weeks learning Java with Sparta Education. This is the final project to test and display our skills. We worked as a team to create a project that allows the user to choose playing between snap and blackjack. We must include unit tests, documentaion of task allocation, and give a 20 minute presentation on the project.