CS 112 - Introduction to Computer Science II
Homework #6


Due: Wednesday 10/11 at the beginning of class

NOTE: This work is to be done in pairs.  This means that each team will perform one submission with all team names and studentIDs listed in the README file after the honor pledge.  Although team members can divide work, each team member should be able to informally present all work of his/her teammate.

1. Game Interface (due Friday 10/6): Implement a simple text-based game (e.g. Nim, Connect Four, Blackjack, etc.) according to the Game interface we define in class.  For game ideas, see The New Games Treasury by Merilyn Simonds Mohr (Houghton Mifflin, 1997), available in our library (reference section GV1201.M67 1997).

2. Lights Out:  In this exercise, you'll be implementing a puzzle called Lights Out in a file called LightsOut.java.  Lights Out is a puzzle where one seeks to get all lights out in a grid of lights.  Turning a light on/off is accomplished by clicking on the bulb.  However, this also toggles horizontally/vertically adjacent lights on/off.  The puzzle starts in its solved state.  To play, click a number of positions to scramble it and see if you can return it to the solved state!

 

  

Above are two screen shots of an implementation.  Two files, bulbOnSmall.gif and bulbOffSmall.gif, are needed as button icons.  Read Sun's tutorial on "Using Layout Managers".  The buttons are laid out in a 5x5 grid.  The JPanel method pack() should be called after adding all components to properly size the JFrame with respect to its components.