首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
代写COMP1721、代做Java程序语言
项目预算:
开发周期:
发布时间:
要求地区:
COMP1721 Object-Oriented Programming
Coursework 2
1 Introduction
Your task is to implement a simulation of the card game Baccarat—specifically, the simpler ‘punto banco’
variant of the game. To assist you, we have provided three Java classes: Card ,CardCollection and
CardException. These should form the basis of your solution.
Please note: an absolute requirement of this assignment is that you should not alter the definitions of
the Card, CardCollection andCardExceptionclasses in any way.
2 Preparation
1. Start by learning the rules of the game! Consult the Wikipedia page on Baccarat, which has a very
good summary. Note that you only need to read the sections headed ‘Punto banco’ and ‘Tableau
of drawing rules’.
2. Download the Zip archivecwk2files.zip from Minerva.
3. Unzip the Zip archive. You can do this from the command line in Linux, macOS and WSL 2 with
unzip cwk2files.zip. This will give you a subdirectory named cwk2, containing all the files you
need. Then remove the Zip archive, to ensure that you don’t accidentally submit it as your
solution!
4. Study the files in cwk2. In particular, examine the file README.md, as this provides guidance on how
to run the tests on which your mark will be partly based.
3 Basic Solution
For the basic solution, you must implement these classes:
• BaccaratCard, to represent a single playing card in Baccarat
• BaccaratHand, to represent a hand of cards in Baccarat
• Shoe, to represent the ‘shoe’ from which cards are dealt in Baccarat
You will also need to implement a small program in Baccarat.java that uses the classes.
The files for all of these classes can be found in src/main/java. Your solution MUST be implemented
in these files, in this specific location!
Figure 1 shows the relationships that should exist between the three main classes, and the methods they must
support. Relationships with the other provided classes are not shown.
Before writing any code, think carefully about the best way to reuse the Card and CardCollection
classes that we have provided to you.
Figure 1: Classes needed for Baccarat simulation.
As in Coursework 1, we have provided tests that will help you check whether you have implemented the
classes correctly. Some of the code needed to pass the tests is in the classes we have provided, but you will
1
need to also write stubs for some of the methods in Figure 1 in order for the tests to compile and run—see
the instructions for Coursework 1 if you need a reminder of how to do this.
As in Coursework 1, the tests are run using Gradle:
./gradlew test
Omit the ./ prefix if running in a Windows command shell, or use .\gradlew.bat to invoke Gradle
if running in Windows Powershell. If using IntelliJ, you should also be able to run the tests and other
coursework-related tasks via that IDE’s Gradle tool window.
The following sections provide further details of the requirements for each of the three classes.
3.1 BaccaratCard
These are the minimum requirements for the tests to pass.
• It should be possible to create a BaccaratCard object by specifying a rank and a suit, where the rank
is an instance of the enum Card.Rank and the suit is an instance of the enum Card.Suit .
• It should be possible to query rank and suit via the getRank() and getSuit() methods.
• Calling toString() on a BaccaratCard object should return a two-character string in which the first
character is the rank (A, 2, 3. . .9, T, J ,Q, K) and the second character is the Unicode symbol for the
card’s suit:♣ (\u2663), q (\u2666), r ( \u2665), or ♠ (\u2660).
• It should be possible to compare BaccaratCard objects in two ways, using the equals() and
compareTo() methods. These methods should have the expected behaviour for Java classes, as
discussed in the lectures. They should use rank and suit to perform their comparisons.
• The value() method of BaccaratCard should return the points value of the card in the game of
Baccarat. (See the Wikipedia article for details of scoring.)
Remember that we have provided a Card class to help you with implementation. Some of the requirements above are satisfied by code in that class. Think about the best way of reusing this code.
3.2 BaccaratHand
These are the minimum requirements for the tests to pass.
• A BaccaratHand should be able to store BaccaratCard objects, but it should start out as empty.
• It should be possible to add a BaccaratCardobject to a BaccaratHand by calling the add() method.
• Calling size() on a BaccaratHand should return the number of cards in the hand.
• Calling toString() on a BaccaratHand should return a string containing two-character representations of each card, separated from each other by a space. For example, a hand containing the Ace of
Clubs, Four of Diamonds and Jack of Spades should yield “A♣4q J♠”.
• The value() method of BaccaratHand should return the points value of a hand in the game of
Baccarat. (See the Wikipedia article for details of scoring.)
• The isNatural() method of BaccaratHand should return true if the hand has two cards and a points
value of 8 or 9, false otherwise.
Remember that we have provided a CardCollection class to help you with implementation. Some of
the requirements listed above are satisfied by code in that class. Think about the best way of reusing
this code.
3.3 Shoe
These are the minimum requirements for the tests to pass.
• Shoe must have a constructor in which the number of decks of cards is specified as a parameter. This
can have values of 6 or 8; any other value should result in a CardException being thrown.
• The constructor of Shoe should ensure that a shoe stores the specified number of complete decks of
BaccaratCard objects. A deck of cards is the full set of 52 cards, ordered first by suit and then by
rank. The constructor should not reorder the cards in any way.
2
• Calling size() on a Shoe should return the number of cards in the shoe.
• The shuffle() method of Shoe should reorder the cards in the shoe randomly. Java’s Collections
utility class, from the java.util package, will help you implement this easily. See the documentation
of this class for more details.
• The deal() method of Shoe should remove the first stored card and return it to the caller. Attempting
to deal from an empty shoe should trigger a CardException.
Remember that we have provided aCardCollection class to help you with implementation. Some of
the requirements above are satisfied by code in that class. Think about the best way of reusing this
code.
3.4 Main Program
The final part of the Basic solution is to implement a small program in Baccarat.java that uses the three
classes discussed earlier. This program should
• Create a shoe containing 6 full decks of cards, and shuffle it
• Create hands for the banker and a single player
• Deal a card to player then banker, then repeat this so each hand has two cards
• Display the contents and value of each hand
• Inform the user if the player or banker has a Natural
You can run the program via Gradle, with
./gradlew run
Figure 2 gives an example of the output that the program should generate.
Figure 2: Sample output for the Basic solution.
4 Full Solution
For the Full solution, replace the program in Baccarat.java with a more complete simulation of the game.
Your simulation should follow a simplified version of the ‘punto banco’ rules outlined in the Wikipedia
article. In this version, there is no betting and you should not ‘burn’ any cards from the shoe.
In this more complete simulation, the program will need to play multiple rounds, indicating the result
(Banker win, Player win or Tie) after each round. See the subsections below for further details.
Note: marks for the Full solution will be awarded based on how much of the required behaviour you
are able to implement correctly, and also on how well designed your solution is. A fully object-oriented
implementation in which different aspects of the task are broken out into separate methods will score more
marks than an unstructured implementation where everything is contained within the main method.
4.1 Interactive Mode
If the Baccarat program is run with a single command line argument whose value is either "-i" or
"--interactive" , then it should operate in interactive mode. In this mode, the program should continue
playing the game provided that there are at least six cards remaining in the shoe and the user has indicated
a wish to continue. The program should check this with the user at the end of each round. If the user’s
response does not begin with either 'y' or 'Y' then the game should end.
At the end of the game, the program should display counts of the number of rounds played, the number of
player wins, the number of banker wins and the number of tied rounds. After displaying this information,
the program should terminate.
3
A sample of the expected program output can be seen in Figure 3.Here, the user indicated that they wanted
to finished after playing ten rounds.
Figure 3: Sample output for Full solution (interactive mode).
To test interactive mode using Gradle, do
./gradlew interact
4.2 Non-Interactive Mode
If theBaccarat program is run without command line arguments, it should operate without user interaction,
playing rounds of the game repeatedly until there are fewer than 6 cards remaining in the shoe. At this point,
the program should display the same ‘end of game’ statistics as it does in interactive mode. The program
should then terminate.
Non-interactive mode should be the behaviour seen when running the program with
./gradlew run
5 Submission
Use Gradle to generate a Zip archive containing all the files that need to be submitted:
./gradlew submission
This produces a Zip archive named cwk2.zip. Submit this file to Minerva, via the appropriate link in the
‘Submit My Work’ folder.
The deadline for submissions is 2 pm on 2 May 2024. The standard university penalty of 5% of available
marks per day will apply to late work, unless an extension has been arranged due to genuine extenuating
circumstances.
Note that all submissions will be subject to automated plagiarism checking.
4
6 Marking
20 Tests for main classes (BaccaratCard ,BaccaratHand ,Shoe )
10 Code structure and style for main classes
5 Basic Baccarat program functionality, if Full solution not attempted
15 Full Baccarat program functionality (replaces Basic)
10 Full Baccarat program structure and style
60
Note: there are either 5 marks or 15 marks available for correct functioning of the program that uses the
classes, depending on whether you’ve attempted the Basic solution or the Full solution.You are also assessed
on program structure and style if you attempt the Full solution, but not if you attempt the Basic solution (as
the amount of code required in this case is very small).
Thus the maximum mark that can be achieved for the Basic solution is 36.You can achieve up to 60 marks
if you attempt the Full solution.
5
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!