首页 > > 详细

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.

联系我们 - QQ: 99515681 微信:codinghelp2
© 2014 www.7daixie.com
程序代写网!