CS 112 - Introduction to Computer Science II
Homework #12

Due: At the beginning of class 36.

NOTE: This work is to be done in pairs.  I strongly recommend the practice of Pair Programming described simply here.  Although team members are permitted to divide work, each team member should be able to informally present all work of his/her teammate.

Binary File I/O

1. Double File Conversion: In this exercise you will implement DoubleFileConverter.java according to this specification.

Consider the following three ways a list of double may be written out to a file:

Your task is to demonstrate an ability to write out and read in a list of doubles in any of these formats.

2. Two-Bit Random Access File: In this exercise you will modify BitRandomAccessFile (described in class) to allow the random access reading and writing of unsigned two-bit values (0, 1, 2, 3) in a file with TwoBitRandomAccessFile according to this specification.

Note:

Guidance for implementation: Start with a copy of BitRandomAccessFile.java and rename it to TwoBitRandomAccessFile. In this file, you'll need 4 mask values for binary two-bit ranges 0b11000000, 0b00110000, 0b00001100, and 0b00000011. You'll also use integer division and modulus with 4 rather than 8.

3. Traffic Lights Solver: In this exercise, you will implement an algorithm that uses your TwoBitRandomAccessFile to compute and store whether or not each possible state in a 3-by-4 Traffic Lights game is a winning or losing state. Beginning with this starter code (including eval method pseudocode) implement TrafficLightsSolver to this specification

NOTE: This is a computationally intensive task, so testing may take several minutes.  You may want to set COLS = 3 for your own testing phase.  For submission (after you've thoroughly tested!), be sure that COLS = 4 and that there is no extra printing beyond that which is supplied.  As before, any excess printing that fills the submission system with large amounts of output will result in a 1 point (5%) deduction.

 

Rubric: (20 points total)