Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Task 2 : Scoring a blackjack hand This exercise counts towards your mark for Assessment Task 2 ( Final Assignment ) . Make sure you
Task : Scoring a blackjack hand
This exercise counts towards your mark for Assessment Task Final Assignment Make sure you complete it by :pm Sunday the nd of June to avoid any late penalties.
As an assessed task, it's important that you complete it on your own. Any code that you submit for this exercise must be composed entirely within this page. You must not submit code that you have obtained from peers or any other source. For details, please see An important warning in Everything you need to know about this subject.
This task will be difficult if not impossible to implement without using collections, which will be taught in Week We recommend you skip this task until then.
In this task you will implement a Scorer class for scoring a hand of blackjack, and deciding if it is bust or not.
Background
In blackjack, the score of a player is determined by their hand of cards. More specifically, it's determined by the ranks of their cards suits have no effect on scores :
Each numeric card is worth the same as the card's rank. For example, a of hearts is worth points, a of diamonds is worth points, etc.
Each of the face cards Jack, Queen and King are worth points.
The ace is worth either point or points the player is free to choose
The objective is to get a hand with a score that is as close as possible to without going over. If the player gets a score that is over they go "bust" and loose the round.
Specification
The Scorer class must provide the following methods:
A static getScore method, which accepts a hand of cards as List of Card and returns the score of this hand. This score must be calculated according to the rules described in the Background section above. If there are Aces in the hand, then this score must make the best use of them to ensure the score is as high as possible without going bust unless going bust is unavoidable
A static isBust method, which accepts a hand of cards as List of Card and returns true if the hand is bust, or false if it is not. The logic for deciding whether a hand is bust is described in the Background section above.
Available classes and methods
Your workspace includes compiled versions of the Suit enum and the Card and Deck classes, all of which have been implemented exactly as specified in Task You won't be able to see the source code of these classes, but you can can and should use them in your solution. Refer back to the task description for details about how these classes work and which methods they have.
We have provided a Runner class with a main method that will be executed when you click the Run button. You are welcome to change this method however you like. This file is not used in testing and is provided purely to allow you to interact with and explore your own code.
Examples
Here are some examples of the output of the runner if you leave it unchanged, and implement the classes correctly:
Getting on the draw:
Starting Hand:A J Score:
Going bust without any aces
Starting Hand: Score:
Hand: Score:
Hand: Score:
Bust!
Getting with an ace
Starting Hand:A Score:
Hand:A Score:
Hand:A Score:
Going bust with an ace
Starting Hand: A Score:
Hand: A Score:
Hand: A Score:
Hand: A K Score:
Bust!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started