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
- Create a package lab.games.
- 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.
- Save the files empty.jpg,
player.jpg and computer.jpg
in directory workspace/project, where project is the name
of the Java project.
- In the constructor of the View class, set the title of the frame to
the string "Connect 4".
- Implement the setSlot method of the View class.
- Test the View class using the JUnit test
ViewTest.
- Implement the actionPerformed method of the Controller class.
- Test the Controller class using the JUnit test
ControllerTest.
Part II
- Replace the Model class with this Model class.
- 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.
- 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).
- Transfer your Java classes to your EECS account (if they are not
already there).
- Create a file named group.txt in the directory
which contains the lab directory which contains the games
directory which in turn contains the Java classes. Do not put
the group.txt in the same directory as Java classes.
Each line of the file group.txt contains the EECS login name of
a member of the group.
- Submit your Java classes: Model, View and Controller. Each class
should be submitted separately as follows. Open a terminal and go to the
directory that contains the file group.txt. In that directory,
run the following command to submit your Model class.
submit 1030 lab7 group.txt lab/games/Model.java
If something fails, you may see something like
submitted: group.txt (17 bytes)
submitted: Model.java (1270 bytes)
All files successfully submitted.
Your Model class compiled successfully.
isFilledRecursive can take Model.COLUMN as its argument
java.lang.AssertionError: isFilledRecursive can take Model.COLUMN as its argument
SUBMITTED FILE Model.java HAS BEEN REMOVED.
PLEASE SUBMIT AGAIN.
Fix your code and submit again. If you successfully submitted your code,
you will see something like this
submitted: group.txt (17 bytes)
submitted: Model.java (1270 bytes)
All files successfully submitted.
Your Model class compiled successfully.
Your Model class passed all the tests.
Your code contains no style errors.
Your group.txt file has been successfully validated.
- You can check which files you have successfully submitted by opening
a terminal and running the following command.
submit -l 1030 lab7
After submitting your Model class, you should see something like this
The following files have been submitted:
The following files have been submitted:
group.txt.submitted 17 bytes
View.java.submitted 2692 bytes
Controller.java.submitted 3231 bytes
Model.java.submitted 10392 bytes
- If you run into problems with submitting your Java classes, please
email franck@cse.yorku.ca.