ITE3101 Introduction to Programming Assignment (2018/19)
Page 1
ITE3101 Introduction to Programming
Programming Assignment Due Date: 7 Dec 2018 (FRI)
Notice to Students
1. This assignment should be written by individual student. All downloaded materials are
not allowed.
2. Plagiarism will be treated seriously. All assignments that have been found involved wholly
or partly in plagiarism (no matter these assignments are from the original authors or from
the plagiarists) will score ZERO marks.
3. Your program must use Java JDK1.8 or above to develop.
4. Your program must be structured and well commented.
The first few lines in the source file must be comments stating the name of the source file,
student name, student ID, course name, course code, and brief description of your
program.
/********************************************************
Name of Source File: PokerGame.java
Student Name (ID): Chan Tai Man (183456789)
Course Name (Code): HD in GA (IT114206)
Program Description:
This program is . . . . . . .
. . . . .
. . . . .
********************************************************/
Marks will be deducted if such comments are not included.
5. Write?down your test cases and the reason(s) for them. Test your program by using your
test cases.
6. You are required to hand a zip file containing the following 2 items via the assignment
link in Moodle:
a. A Java Program file (PokerGame.java + PokerGame.class), including detailed
comments
b. A Microsoft Word file (TestResult.doc) stores all screens captured of your test cases
8. Weight of this assignment is 20% of the module total assessment.
ITE3101 Introduction to Programming Assignment (2018/19)
Page 2
Poker Game
Distribution of marks:
30% for Problem solving technique, e.g. algorithms
30% for Java programming technique, e.g. statements, control structures, etc.
20% for good program styles, e.g. naming, comments, etc.
20% for the evidence of Testing, e.g. test case, test result, etc.
Problem Specification:
You are asked to develop a Java Program that designs a simple Poker game.
A standard deck of cards has 52 cards. Each card has a value and a suit. Values contain
Ace(A), 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack(J), Queen(Q), and King(K). The four suits are Clubs,
Diamonds, Hearts and Spades. Clubs and Spades are Black, while Diamonds and Hearts are
Red.
In this game, we design our game rules and score as follow:
Poker Rule Description Score
Straight Flush 5 cards in sequence in the SAME suit 8
Four of a Kind 4 cards of the SAME rank and any other card 7
Full House 3 of a kind and a Pair 6
Flush 5 cards of the SAME suit that are not all in sequence 5
Straight 5 cards in sequence but not all of the same suit 4
Three of a Kind 3 cards of a the same rank and 2 unmatched cards 3
Two Pair 2 sets of 2 cards of a the same rank and an unmatched card 2
One Pair 2 cards of a the same rank and 3 unmatched cards 1
No Pattern is Found! 0
ITE3101 Introduction to Programming Assignment (2018/19)
Page 3
Our final Poker Game interface can be shown as below (for your reference ONLY, you can
design your own game interface):
Refer to the previous diagram, Example set of 52 playing cards, you may construct
an integer array, int[] order, to shuffle the order of 52 cards, and
two double integer arrays, int[][] humanCards / computerCards, to store the collected
5 cards for each round.
A 2 3 4 5 6 7 8 9 10 J Q K
Clubs (C) 0 1 2 3 4 5 6 7 8 9 10 11 12
Diamonds (D) 13 14 15 16 17 18 19 20 21 22 23 24 25
Hearts (H) 26 27 28 29 30 31 32 33 34 35 36 37 38
Spades (S) 39 40 41 42 43 44 45 46 47 48 49 50 51
humanCards /
computerCards
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]
[0] CA C2 C3 C4 C5 C6 C7 C8 C9 CT CJ CQ CK
[1] DA D2 D3 D4 D5 D6 D7 D8 D9 DT DJ DQ DK
[2] HA H2 H3 H4 H5 H6 H7 H8 H9 HT HJ HQ HK
[3] SA S2 S3 S4 S5 S6 S7 S8 S9 ST SJ SQ SK
ITE3101 Introduction to Programming Assignment (2018/19)
Page 4
To build your simple Poker Game program, you may consider the following:
Prompt for the Player Name and check for the proper Game Rounds
Player Name supports ANY strings input
Game Rounds only supports integer input between 2 to 10
In order to simplify your main() method, it is suggested to write a set of following methods:
Method Action
void PrintTitle(player); ? Print a title with Player’s name and Computer
heading
For each game round,
void ResetCards(humanCards,
computerCards);
Reset values of both double integer arrays, int[][]
humanCards / computerCards, to 0
void Set5Cards(order, humanCards,
computerCards);
Shuffle the order of 52 playing cards
Distribute the 5 cards to human and computer in
turns
void PrintRoundHeading(current
round);
Print the round number
Print the cards heading for player
Print the cards heading for computer
void Print5CardsInfo(humanCards,
computerCards);
Show the 5 cards that player received and computer
received with some graphic design
String CalculateCards(humanCards /
computerCards);
Refer to the our previous game rules table, consider
the result of the given 5 cards pattern
int CardsScore(humanResult /
computerResult);
Refer to the our previous game rules table, map the
score from the cards result
void PrintRoundResults(humanResult,
current humanScore, computerResult,
current computerScore);
Print the game round results and scores of player
and computer
void PrintSummary(player,
hScoreTotal, cScoreTotal);
After all game rounds, print the winner
Design your own graphic for game is finished
ITE3101 Introduction to Programming Assignment (2018/19)
Page 5
Further Analysis and Extra Helping:
To shuffle the order of 52 playing cards, it is suggested to write a method, public static int[]
ShuffleCards()
To build an integer ArrayList with code:
List<Integer> cardOrderList = new ArrayList<Integer>();
To random the 52 orders, using the code:
Collections.shuffle(cardOrderList);
Now the ArrayList is replaced by an integer array with code pattern:
Iterator<Integer> iterator = cardOrderList.iterator();
... ...
... ... iterator.next().intValue();
The method, public static String CalculateCards(int[][] cards), is the heart of this Poker
Game:
Set 4 Boolean variables, isAllClubs, isAllDiamonds, isAllHearts, isAllSpades
Set Boolean variables, isOneDiff, isPairFound, isThreeKind (for checking cards pattern)
o if the first rowTotal of cards = 5, isAllClubs = true;
o if the second rowTotal of cards = 5, isAllDiamonds = true;
o if the third rowTotal of cards = 5, isAllHearts = true;
o if the four rowTotal of cards = 5, isAllSpades = true;
If either one of (isAllClubs, isAllDiamonds, isAllHearts, isAllSpades)
is TRUE,
o Check the 5 card’s positions are adjacent and result is “Straight Flush”, otherwise
result is “Flush”
If ALL of (isAllClubs, isAllDiamonds, isAllHearts, isAllSpades) are
FALSE,
o If ANY column total of cards are >=2, break;
o If the column total of cards is <2, check if the 5 card’s positions are adjacent and
result is “Straight”
If a column total of cards = 4, result is “Four of a Kind”
If a column total of cards = 3, isThreeKind = true;
If a column total of cards = 2, isPairFound = true;
o If another (isPairFound) is found, result is “Two Pair”
If both (isThreeKind, isPairFound) are TRUE, result is “Full House”, otherwise
result is “Three of a Kind”
If only one (isPairFound) is TRUE, result is “One Pair”
If NONE of the above, then “No Pattern is Found!”
版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。