2023 removed Programming Assignment 4 Overview The goals of this section are to | Assignment Collections

Computer Science 2023 Programming Assignment

2023 removed Programming Assignment 4 Overview The goals of this section are to | Assignment Collections

 

 
 

 

 

 

 

 

 

[removed]

 

 

 

 

 

 

 

 

 

 

 

 

 
Programming Assignment
4

 

Overview
The goals of this
section
are to:
1.
Use methods
2.
Break down a problem into small tasks to implement
S
etup
This assignment requires one starter file. Set up your directory via:
$ mkdir HW4
$ cd HW4
$ cp
/ho
me
/linux/ieng6/cs11wb/public/HW4
/*
.
Poker
(40 pts)
By the end of this assignment you will have created a program that can
compare two poker
hands and declare a winner.
If you’ve never played poker, review
wikipedia
for the list of
winning hands (in order):
straight flush
four of a kind
full house
flush
straight
three of a kind
two pair
one pair
high card
We will be storing both the card values and suits in arrays. Values
will range from:
Number
Representation
Card
Value
1
A (Ace)
2
2
3
3
4
4
5
5
6
6
7
7
8
8
 
9
9
10
10
11
J (Jack)
12
Q (Queen)
13
K (King)
And suits will be stored with chars:
Char
Representation
Suit
Value
S
Spades
D
Diamonds
H
Hearts
C
Clubs
Step 1
(5 pts)
:
enter a hand of cards
Allow the user to in
put the hand of a single player. You must store this into arrays. My solution
used 2 arrays, one for the card value and one for the card suit. I
t should look
exactly
like this:
Enter Player
1’s cards
:
1 S 2 C 10 D 12 H 13 D
This hand represents:
Ace of spades, 2 of clubs, 10 of diamonds, Queen of hearts, and King of diamonds.
Note
: it is safe to assume that we will only enter numbers between 1
13 and we will only
enter characters S, D, H, and C. When we test your code, we will follow the rules of input, so it
is not necessary to check for bad input.
Step 2 (5 pts): print playe
r’s cards
Print out the cards of the player. This should happen in its own method. Your code should now
result in
exactly
the following:
Enter Player 1’s cards:
1 S 2 C 10 D 12 H 13 D
Player 1’s hand:
AS 2C 10
D QH KD
Step 3 (15
pts):
Discover player’s
poker hand
Print out
the hand of the player, e.g. FULL HOUSE, FOUR OF A KIND, etc. You should select the
best hand. That is, if a player has 3 queens and 2 jacks, you would say they have a FULL HOUSE,
not
three of a kind. You should create methods to test for each possible hand. This will result in
8 methods (
high card
does not require a method).
Don’t forget the Ace can be high
or
low in a
run, e.g. A, 2, 3, 4, 5 is a straight, and 10, J, Q, K, A also cou
nts as a straight.
Critical at this point
: cards will be entered in
numerical order, e.g. 1, 2, 3, … 11, 12, 13.
This is
HUGE
and will be a key assumption that
you can follow in your program, and wil
l make this
program much easier. This is my gift to you.
Here’s some example runs. Make sure your code prints out these exact hands, this is how we’ll
be testing your code.
Enter Player 1’s cards:
1 S 2 C 10 D 12 H 13 D
Player 1’s hand:
AS 2C 10
D QH KD
B
est hand: HIGH CARD
Enter Player 1’s cards:
1 S 2 S
3 S 4 S 5 S
Player 1’s hand:
AS 2S 3S 4S 5S
Best hand: STRAIGHT FLUSH
Enter Player 1’s cards: 1 D 10 C 11 S 12 H 13 H
Player 1’s hand:
AD 10C JS QH KH
Best hand: STRAIGHT
Enter Player 1’s cards: 10 D 10 H 10 C 13 H 13 D
Player 1’s hand:
10D 10H 10C KH KD
Best hand: FULL HOUSE
Enter Player 1’s cards:
2 C 2 H 5 D 11 D 11 C
Player 1’s hand:
2C 2H 5D JD JC
Best hand: TWO PAIR
Step 4 (10 pts)
:
Allow a 2
nd
player to enter their cards, print cards and hand
This will happen in the same fashion as player 1. You should not need to duplicate code to do
this, make sure you’re u
sing methods. If we see
duplicated code, we will deduct
half points for
this section. Your code should now look like this:
Enter Player 1’s cards: 1 S 2 S 3 S 4 S 5 S
Player 1’s hand:
AS 2S 3S 4S 5S
Best hand: STRAIGHT FLUSH
Enter Player 2’s cards: 2 C 2 H 5 D 11 D 11 C
Player 2
’s hand:
2C 2H 5D JD JC
Best hand: TWO PAIR
Step 5 (5 pts)
:
Print the winner or tie
Print the player that has the winning hand. If both players have the same hand, e.g. both
players have a full house, print there’s a tie. This isn’t what happens in poker, but I’m
making
the decision to make this part of the assi
gnment easier, so just print
Tie
. Here’s some
example runs.
Enter Player 1’s cards: 1 S 2 S 3 S 4 S 5 S
Player 1’s hand:
AS 2S 3S 4S 5S
Best hand: STRAIGHT FLUSH
Enter Player 2’s cards: 2 C 2 H 5 D 11 D 11 C
Player 2
’s hand:
2C 2H 5D JD JC
Best hand: TWO PAIR
Player 1 wins!
Enter Player 1’s cards: 1 S 2 S 3 S 4 S 5 S
Player 1’s hand:
AS 2S 3S 4S 5S
Best hand: STRAIGHT FLUSH
Enter Player 2’s cards: 1 D 10 D 11 D 12 D 13 D
Player 2
’s hand:
AD 10D JD QD KD
Best hand: STRAIGHT FLUSH
Tie!
Programmer of the week
(optional)
If you’d like to compete in the programmer of the week challenge, you must complete the
above part of the assignment as described. Once you get that to work, create another class,
POWeek.java, and start to extend the poker game. If you know how
to use javafx or java.swing,
you could include graphics. You could implement betting, support multiple players, allow for
cards being dealt instead of being input by the user, handle ties, change to Texas hold ‘em, etc.
Your tutor will present your submi
ssion at our weekly meeting and we’ll vote for the top 5
submissions from each class and show those to the students to vote for the programmer of the
week. The winner will get an award, 1% extra credit added to their final grade, and be famous
for a week.
Note: we will only be looking at the running of the code, i.e.
we will not count off
for anything done in the POWeek.java submission.
Style Requirements
(10 pts)
Different from other assignments
You will be graded for the style of programming on this assignment.
We are adding javadoc
comments as a requirement to the assignment
.
Use reasonable comments
to make your code clear and
readable.
(N
ew)
All methods must have javadoc comments
. We will be
testing this by running
“javadoc filename.java” and ensuring that the resulting documentation pages appear.
Use
reasonable variable names
that are meaningful.
Use static final
constants to make your code as general as possible. No ha
rdcoding
constant va
lues inline (no magic numbers).
o
Note
(new)
: There will be many cases in this homework where you want to
compare card 1 to card 2, card 2 to card 3, etc. I’m allowing you to hardcode
numbers for this.
Judicious use of blank spaces
around logical chunks
o
f code makes your code much
easier to read and debug.
Keep all lines
less than 80 characters
.
M
ake sure each level of indentation lines up
evenly.
Every time you open a new block of code (use a ‘{‘),
indent farther by 2 spaces
. Go back
to the previous le
vel of indenting when you close the block (use a ‘}’).
Always recompile and run your program right before turning it in, just in case you
commented out some code by mistake.
Turnin Instructions
Remember the deadline to turn in your assignment is
Saturday, January 30
by 11:59pm.
When you are ready to turn in your program in, type
in the following command and answer the
prompted questions
:
$ cd ~/
$
bundleP4
Good; all required files are present:
HW4
Do you want to go ahead and turnin
these files? [y/n]y
OK. Proceeding.
Performing turnin of approx.
6144
bytes (+/
10%)
Co
pying to /home/linux/ieng6/cs11wb
/turnin.dest/cs
11wb
.P4
Done.
Total bytes written:
31744
Please check to be sure that’s reasonable.
Turnin successful.

 
 
 
 
 

[removed]

 
 
 
 
 
 
 
Part 1: Poker
Pts for
Correct
Step 1. Are you prompted to enter a hand? Can you enter in the
following hand:
1 S 10 C 11 D 12 C 13 S
All or no points for this.
5
Step 2: Double check the output for each of these hands:
1 S 10 C 11 D 12 C 13 S ==>
AS 10C JD QC KS
1 D 1 C 8 S 9 H 11 H
AD AC 8S 9H JH
-1 pt for each letter missed, e.g. 1 not converted to A.
5
Step 3: Test each hand and result (-1 for each one wrong):
1 S 10 S 11 S 12 S 13 S ==> Straight Flush
1 S 2 S 3 S 4 S 5 S ==> Straight Flush
1 S 10 S 11 S 12 S 13 D ==> Straight
1 S 9 S 11 S 12 S 13 S ==> Flush
1 S 1 D 1 H 1 C 2 C = 4 of a kind
1 S 2 S 2 D 2 C 2 H = 4 of a kind
1 S 1 H 1 D 2 C 2 D = Full house
1 S 1 H 2 D 2 C 2 S = Full house
1 S 1 D 1 H 2 C 3 S = 3 of a kind
1 S 2 C 2 D 2 H 3 S = 3 of a kind
1 S 2 C 3 S 3 D 3 H = 3 of a kind
1 S 1 D 2 S 2 D 3 C = 2 pair
1 S 1 D 2 S 3 C 3 S = 2 pair
1 S 2 C 2 D 3 S 3 D = 2 pair
1 S 1 D 2 C 3 D 4 H = 1 pair
1 S 2 D 2 C 3 D 4 H = 1 pair
1 S 2 D 3 C 3 D 4 H = 1 pair
1 S 2 D 3 C 4 H 4 C = 1 pair
1 S 2 C 4 C 5 D 6 H = High Card
15
Step 4: Can you enter a 2nd player’s hand? (2 pts)
Does the 2nd players hand print as expected (2 pts – see above for
examples)
Does the correct hand show up (1 pt – see above for example)
How much duplicated code is there to get this step to work? (-1 pt
for each major section of duplicated code. Max of -5)
10
Step 5: Comparing hands. Run the following tests (-1 for each
wrong):
P1: 1 S 10 S 11 S 12 S 13 S
P2: 1 S 2 S 3 S 4 S 5 S
Result: Tie!
P1: 1 S 10 S 11 S 12 S 13 S
P2: 1 S 2 S 3 S 4 S 5 D
Result: Player 1 Wins
P1: 1 S 9 S 11 S 12 S 13 S
P2: 1 S 1 D 2 C 3 D 4 H
Result: Player 1 Wins
P1: 1 S 2 S 2 D 2 C 2 H
P2: 1 S 1 H 1 D 2 C 2 D
Result: Player 1 Wins
P1: 1 S 2 C 4 C 5 D 6 H
P2: 3 D 7 C 8 H 10 D 12 D
Result: Tie!
5
COMMENTS
Total
40
Description (Deduct up to Twice for Each Infraction up to 10
points)
Pts for
Correct
Part 3: Style Requirements (10 points)
-1 point for each missing class/file header (only has to be one or
other, They don’t need a file & class header)
-1 point for each missing method header. They must be in javadoc
format. /** */ with @param and @return if used in the method.
-2 point for no inline comments
-1 point for each meaningless variable name
-1 point for each hardcoded constant besides standard 0-4 as
outlined in HW writeup. For this assignment they can do card[0]
== card[4].
-2 point for no logical blank space separators
-1 point for each line over 80 characters
-1 point for each line indented incorrectly
Make sure you find all style errors and report them to your
students, even if they have hit the 10 points deduction limit.
An example of how to deduct points. Let’s say there are 10 lines
that go over 80 characters and everything else is great. They
would loose 2 points total and get 8 pts for style
10
COMMENTS
Total
10
Total Score
50

 

 

We give our students 100% satisfaction with their assignments, which is one of the most important reasons students prefer us to other helpers. Our professional group and planners have more than ten years of rich experience. The only reason is that we have successfully helped more than 100000 students with their assignments on our inception days. Our expert group has more than 2200 professionals in different topics, and that is not all; we get more than 300 jobs every day more than 90% of the assignment get the conversion for payment.

Place Order Now

#write essay #research paper #blog writing #article writing #academic writer #reflective paper #essay pro #types of essays #write my essay #reflective essay #paper writer #essay writing service #essay writer free #essay helper #write my paper #assignment writer #write my essay for me #write an essay for me #uk essay #thesis writer #dissertation writing services #writing a research paper #academic essay #dissertation help #easy essay #do my essay #paper writing service #buy essay #essay writing help #essay service #dissertation writing #online essay writer #write my paper for me #types of essay writing #essay writing website #write my essay for free #reflective report #type my essay #thesis writing services #write paper for me #research paper writing service #essay paper #professional essay writers #write my essay online #essay help online #write my research paper #dissertation writing help #websites that write papers for you for free #write my essay for me cheap #pay someone to write my paper #pay someone to write my research paper #Essaywriting #Academicwriting #Assignmenthelp #Nursingassignment #Nursinghomework #Psychologyassignment #Physicsassignment #Philosophyassignment #Religionassignment #History #Writing #writingtips #Students #universityassignment #onlinewriting #savvyessaywriters #onlineprowriters #assignmentcollection #excelsiorwriters #writinghub #study #exclusivewritings #myassignmentgeek #expertwriters #art #transcription #grammer #college #highschool #StudentsHelpingStudents #studentshirt #StudentShoe #StudentShoes #studentshoponline #studentshopping #studentshouse #StudentShoutout #studentshowcase2017 #StudentsHub #studentsieuczy #StudentsIn #studentsinberlin #studentsinbusiness #StudentsInDubai #studentsininternational