首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
program编程设计讲解、辅导Java程序设计、Java留学生编程讲解 辅导R语言程序|讲解留学生Prolog
项目预算:
开发周期:
发布时间:
要求地区:
Page 1 of 6
Instructions:
• Read the SubmissionProcedures.PDF and the Standards.java carefully BEFORE you start.
• Let me know about any typos, clarifications, or questions you may have right away. Do not wait.
• Read the whole assignment before you start.
• Start right away. The sooner you get stuck, the sooner you can get help to get un-stuck.
Assignment overview
Learning outcomes:
You will be working with multi-dimensional arrays and StdDraw (Graphics) for this assignment. I will be providing
you with a GameController which handles the game logic and input, a Board which holds the pieces as well as
the start of a TestClass to help you with testing (you should extend this to add additional testing however). I will
also provide you with a starter ChessPiece class which you will extend.
Additional Notes:
Read Standards.java and SubmissionGuidelines.PDF Carefully & before you start.
Please provide detailed commenting!!!
Assignment Notes & Tips:
Be sure to read the assignment carefully. Include a readme.txt document that specifies the latest commit that will
compile and run. This assignment is as much about learning formatting, commenting, testing, and refactoring
practices as it is about Java. Do not skip steps. Make sure you are testing as you go.
Start early. Read the assignment fully before beginning. We will go through it in the first class after it has been handed
out. That is your chance to ask questions. Seriously, start early. I know you are busy, but it is much easier if you get
stuck early and can get help troubleshooting.
Notes on Academic Misconduct:
Your code should be done entirely by you. Any suspicion of Academic Misconduct or plagiarism will be fully
investigated and can lead to serious academic penalties including 0 on the assignment for a first office, or an F in the
course. Third offences could lead to expulsion from ICM. If you have any questions as to what qualifies as Academic
Misconduct, please discuss it with me.
General Notes:
We will be upgrading our previous Checkers game into a Chess game. Along the way, we will add the ability to read a
board state into a file, properly handle our exceptions and see a useful application of subclasses. We will also practice
operations on multi-dimensional arrays.
Keep an eye out for opportunities to reuse existing code and reduce duplication. Do not be afraid to refactor and
clean up your code from time to time. It will save you time in the long run if it is organized and logical.
Page 2 of 6
You should not change anything in ChessPiece (especially removing private), GameController (other than
uncommenting one line to read from a file instead) or Board. You will have to access what you need in the subclass
using appropriate subclassing techniques.
Phase 0: (Not Optional)
When you first start your project, before writing any code, you will create a new git repo in the same folder. You
should ignore any .class files, or any files associated with your text editor (basically ignore every file type that
appears other then .java or .txt).
Create a new local git repo, then make your first commit here, which will simply be the .gitignore file that was
created with a message (such as "Initial commit" with a list of the types of files ignored.
*Note: It might be a good idea to back up your progress as you go in case you run into issues with git. I just
select the whole project folder and put it in a .zip folder. This will give you a snapshot of your code at that
place and time.
Phase 1: Creating the pieces
To start, we must create our pieces. Create the following new classes : Pawn, Castle, Knight, Bishop, Queen, King
Each of these will be a subclass of ChessPiece.
Provide two constructors for each. The first will accept (String newColor, Board theBoard) and will set the name of
the piece automatically (eg. "Pawn", "Queen"... ) while the second will accept (String name, String newColor, Board
theBoard). Both should be using the constructor in ChessPiece to properly set the values (rather than creating new
variables). You should be able to recycle some code if you are clever about it.
Once the constructors are working (and tested in your test file!) you should provide correct graphics references to
each piece (the png file name). Initialize the graphics variables in ChessPiece as part of the Constructors' process.
At this point, you should be able to load up the pieces of the board and have them appear on the board.
Test your board to make sure it is working.
Phase 2: Adding file reading
Create a new class BoardLoader. This will be responsible for loading a file representing a Board into an actual Board.
Provide the following methods in BoardLoader.
a) public static void loadBoardState(Board theBoard, String fileName)
This accepts both a reference of the board to be initialized as well as the file name to load from. It will
handle the other methods.
Page 3 of 6
b) private static String[][] parseFile(String fileName)
Load the file from disk and return the contents as a 2D array. Each Row will represent one line in the file
while each Col will contain a single token. Be mindful that the files contain the board size at the beginning.
You can skip this (for now) but do not modify the files.
• Tip: Be careful that the white and black positions do not get switched, it should look the same as the
file.
c) private static void loadPiecesFromString(Board targetBoard, String[][] boardCodes)
Accept a 2D array of type String with all the board codes and load the pieces into the board from this.
d) private static ChessPiece loadChessPiece(Board targetBoard, String code)
Creates and returns a single ChessPiece given a String code.
The boards look like this:
BC BN BB BK BQ BB BN BC
BP BP BP BP BP BP BP BP
E E E E E E E E
E E E E E E E E
E E E E E E E E
E E E E E E E E
WP WP WP WP WP WP WP WP
WC WN WB WQ WK WB WN WC
The first Char of each Token is the Color (or E for Empty).
The second is the position
C = Castle
N = Knight
B = Bishop
K = King
Q = Queen
P = Pawn
• Note: String folder = ".\\Boards\\"; // use this to load from the folder. Don't change the layout of the
files. Load them from the correct location. This may work slightly differently depending on your IDE.
• Other note: I have put these different tasks in separate methods to assist with testing so take advantage of it.
Page 4 of 6
Phase 3: Movement and isValidMove
Provide an overriding version of the isValidMove method for each of the subclasses of ChessPiece from Phase 1.
Each will be different depending on the type of piece. I suggest you work out some strategies on paper before you
start coding.
isValidMove lets us know if a proposed move is valid or not. We give it the current position and the goal position
and it will test whether that move can be made (true) or not (false).
Tackle these in any order you like.
Rules:
• Pawn: Can move one tile forward (towards opponent) but cannot capture OR can capture one tile diagonally
forward but only if an opposing piece is there. Pawn is one of the simplest but can only move in the direction
of its color so you will need to handle this separately. Its diagonal attack action is also only valid if there is an
opposing piece there.
• Knight: Can jump over other pieces and travel 2 horizontal spaces and 1 vertical space OR 1 horizontal
space and 2 vertical spaces (in any direction).
• King: Can travel 1 tile in any direction
• Bishop: Can travel n tiles diagonally but cannot "jump" over other pieces
• Castle: Can travel n tiles either horizontally or vertically (one or the other) but cannot "jump" over other
pieces.
• Queen: Can travel n tiles either horizontally, vertically, or diagonally but cannot "jump" over other pieces.
o *n tiles – just means as many tiles as you want in a given direction.
Some tips/hints:
• King is probably the easiest and a good place to start.
• Knight is the only piece that can jump over others. The rest you will have to check for other pieces being in
the way. Detecting other pieces blocking your path is probably the most difficult part.
• Note the similarities between the way pieces move. Can you use this to your advantage somehow?
• A piece can capture an opposing piece but not its own team.
At this point you should make sure you test your code well to ensure everything is working correctly. The methods
drawSelectedForSingleMove and drawSelectedForAllValidMoves are very useful for visualizing whether
your moves are being calculated correctly or not. They will draw green squares on the board if the move is valid / for
all valid moves. See the TestClass I started for you for examples (I expect you to extend and improve on this).
Refactoring checklist:
• Double check the spelling and case (methods are lowercase, classes are Uppercase) against the
assignment doc. It may not seem important but when I run my test classes, this will break all my marking
code. Not a good start to things.
• Make sure all of your variables are private. Most methods can be public for now.
• Make sure you have appropriate accessor methods for what you need.
o Not every variable will need access outside of the class, so think about which ones do.
• Add a comment header at the top of each Class file explaining what it does
• Add a comment above each method explaining what it does. It is also useful to include usage instructions or
useful notes. "Crashes on numbers below 0" for example.
• Make sure your method names make sense and are free of typos.
• Organize your variables so that they are grouped with related variables.
• Just read through your code, add any questions or notes you might have in comments.
• Remove any redundant code (leftover stuff that is not being used).
• Be careful what you remove. Make sure you test again afterwards.
• Never assume it will work without testing it. Small changes can have large effects.
That is all. Congratulations, you are done!
Before handing in your files:
• Revisit all your classes, improving the commenting and formatting.
• Include additional testing in your TestClass.java including edge cases.
• Include a Readme.txt file that includes clear instructions on how to run your code, student name and ID,
and any outstanding issues (i.e. bugs, things that were not sufficiently completed or other notes ) I will be
looking for the Readme.txt file when marking so do not skip it.
I give quite a few marks for the quality, formatting, commenting and general quality of the code. Don't skip this.
Phase 4 (Optional):
I will give you some bonus marks if you go above and beyond the given scope or adding extra features. You should
make sure the rest of the assignment is done first though as the bonus marks will be minor compared to the rest of
the assignment marks. Make sure your new additions DON'T break any of the functionality asked for in the
assignment document. For example having pawns have the additional space they can move on the first turn, detecting
a "check" (not mate) state, showing a graphic when you win/lose or allowing the pawn to change into a different
piece upon reaching the other side (similar to checkers) would all be good chess rules that we are currently leaving
out.
Page 5 of 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
软件定制开发网!