EECS2030 Test 1
Version D
GETTING STARTED
- Save this eclipse project file.
- Start eclipse; use the workspace suggested by eclipse.
- Import the test project by doing the following:
- Under the File menu choose Import...
- Under General choose Existing Projects into Workspace
and press Next
- Click the Select archive file radio button, and click
the Browse... button.
- Navigate to your home directory (the file chooser is probably in
the workspace directory).
- Select the file test1D.zip and click OK
- Click Finish.
- All of the files you need for this test should now appear in eclipse.
Java Standard Library Documentation
Java API
To submit your work
- Open a terminal. You will use this terminal to submit your work.
- Copy and paste the command
cd eclipse-workspace/Test1D/src
into the terminal and press enter.
-
Type the following command and press enter to submit your work:
submit 2030 test1D ChessSquare.java
Question
The standard algebraic notation for describing positions on a chessboard uses
the integer numbers 1-8 to label the rows and the letters a-h to label the
columns of the board; see the figure below:
The rows are called the ranks and the columns are called the
files. The square with coordinates d4 has a file of d
and a rank of 4.
In this question the chess pieces (queen, king, rook, bishop, knight, and
pawn) are identified using the following
strings:
Implement the
class described by this API.
You do not have to include javadoc comments.
-
Start by reading the API to understand what the class does.
-
Decide how many fields you require, what the fields represent,
and what their types are. Add them to your class.
-
Implement the methods
file
, rank
,
and piece
first. The unit tester that
is provided relies on these methods.
-
Implement the constructors.
-
Implement the methods.
-
Use the unit tester to help you, but be aware that the
tests cover only the simplest of cases. It is possible to
receive a failing grade even if your solution passes all
of the given tests.
-
You may modify the unit tester as you see fit.
Hints
The hints below may or may not be useful to you depending on
the types of fields that you decide to use.
-
To get the string representation of any primitive value
x
simply concatenate the empty string with
x
; i.e., "" + x
-
To convert a string to an integer use the method
Integer.valueOf
. Documentation
can be found here.