EECS2030 Test 2
Version C
GETTING STARTED
- 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 test2C.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/Test2C/src
into the terminal and press enter.
-
Type the following command and press enter to submit your work:
submit 2030 test2C Binary.java
Question
Implement the
Binary class described by this API.
Make sure to read the documentation for the Bit
class.
You do not have to include javadoc comments.
You are given a minimal set of unit tests. The
tests are not at all exhaustive. Feel free to modify
or add your own tests.
You are also given a main method. The main method should
output the following:
b : 1001
b.numberOfBits() : 4
b.getLeftMostBit() : 1
b.getRightMostBit() : 1
b.toDecimal() : 9
b.setBit(1, one) : 1101
b.toDecimal() : 13
b.setBit(0, zero) : 0101
b.toDecimal() : 5
b.toDecimal() : 5
b2 copy of b : 0101
b2.equals(b) : true
b3 : 101
b3.equals(b) : true