EECS2030 Test 2

Version C


GETTING STARTED

Begin by downloading and SAVING (NOT opening) the following file found here

  1. Start eclipse; use the workspace suggested by eclipse.
  2. Import the test project by doing the following:
    1. Under the File menu choose Import...
    2. Under General choose Existing Projects into Workspace and press Next
    3. Click the Select archive file radio button, and click the Browse... button.
    4. Navigate to your home directory (the file chooser is probably in the workspace directory).
    5. Select the file test2C.zip and click OK
    6. Click Finish.
  3. All of the files you need for this test should now appear in eclipse.

Java Standard Library Documentation

Java API


To submit your work

  1. Open a terminal. You will use this terminal to submit your work.
  2. Copy and paste the command cd eclipse-workspace/Test2C/src into the terminal and press enter.
  3. Type the following command and press enter to submit your work:

submit 2030 acc 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