Lab 7

This lab will consist of two parts. The first part focuses on graphical user interfaces (and inheritance and aggregation). The second part focuses on recursion.

A graphical user interface often consists of a model, a view and a controller. In this lab, you will be given the partially implemented classes Model, View and Controller and the fully implemented app Main. Together they form the basis for the game Connect 4. In Part I of the lab, you will add some code to the View and Controller classes. In Part II, you will add numerous recursive methods to the Model class.

Part I

  1. Create a package lab.games.
  2. Add the classes View, Model (this class will be reimplemented in Part II) and Controller and the app Main to the package lab.games. Their APIs can be found here.
  3. Save the files empty.jpg, player.jpg and computer.jpg in directory workspace/project, where project is the name of the Java project.
  4. In the constructor of the View class, set the title of the frame to the string "Connect 4".
  5. Implement the setSlot method of the View class.
  6. Test the View class using the JUnit test ViewTest.
  7. Implement the actionPerformed method of the Controller class.
  8. Test the Controller class using the JUnit test ControllerTest.

Part II

  1. Replace the Model class with this Model class.
  2. Implement the methods isFilledRecursive, dropRecursive, and horizontalRecursive. Your implementation has to use recursion. If your method is not recursive, you get a score of zero for the method.
  3. Test the Model class using the JUnit test ModelTest. The JUnit test has been updated March 28. Hopefully, it provides more useful feedback.

Submission instructions

  • Submit your classes before Tuesday March 31, 4pm. To submit, log into a computer of the Prism lab (clips showing how to log in from home and transfer files can be found here).