Warning: Outdated Content
This MP is from a previous version of CS 125. Click here to access the latest version.
Maybe you play them, maybe you don’t, maybe you carry your gaming desktop with you at all times—but regardless of how you feel about it, a fair number of people use computers to play games. Some of those games can be instructive, some can be fun. But an MP where you get to build a fun game is both fun and instructive! For MP3 you’ll be learning Java class design and object-oriented programming as you complete a simple Connect-4-like game.
MP3 is our first two week MP and due Friday 2/23/2018 @ 5PM. To receive full credit, you must submit by this deadline. In addition, 10% of your grade on MP3 is for submitting code that earns at least 40 points by Friday 2/16/2018 @ 5PM. Note that, unlike MP2, you have to do a bit more work on MP3 to get to 40 points—but the early deadline is also later to accommodate that.
As usual, late submissions will be subject to the MP late submission policy.
1. Learning Objectives
The purpose of MP3 is to begin introducing you to object-oriented programming. MP3 does not explore more advanced topics like inheritance, interfaces, or polymorphism. It sticks to the basics: instance and class variables, getters and setters, constructors, and instance and class methods. You’ll begin to learn how to:
design a class that meets a given specification
implement that class including both properly-protected variables and appropriate methods
2. Assignment Structure
Your job is to create and complete
These functions are called by the web server that is set up using
MP3 provides a bit less scaffolding than previous MPs. This is intentional. Eventually you’ll need to write code from scratch, and frequently you’ll need to follow a specification written by other developers or a project manager.
For MP3, the official specification is our
MP3 online documentation.
It should precisely define what each public method in
ConnectN.java should do.
If you believe that the documentation is unclear, please post on
the forum and we’ll offer a clarification is needed.
2.1. Obtaining MP3
2.2. Your Goal
At this point you should be familiar with the requirements from previous MPs. See the grading description below.
2.3. Running MP3
To experiment with the web interface, do the following:
WebServer.javaas a Java application. You’ll need to at least create
ConnectN.javaand get a few things working before the web server will run at all.
Open your web browser and navigate to
At first, nothing will work because you have not implemented any of the required game transformation functions yet.
As far as browser support, we have confirmed that Chrome works. Other browsers may or may not—but Chrome definitely does.
3. Approaching MP3
While the concepts are new, MP3 is not a lot of code to write, and you have two weeks. But here are the bits that are likely to trip you up.
3.1. Read the Fine Manual
To complete MP3 you must understand the specification. That’s your starting point, and your returning point when you get confused.
Writing code to a specification is an important skill to learn. In many software companies, designing code and implementing it are not always done by the same group. A project manager or program manager may write a specification, which is provided to developers to implement. Or a team of developers may come up with a specification, and then divide up the implementation work between them.
Regardless of where it comes from, writing code in groups almost always requires a specification to be successful—unlike when you do independent projects and can make up things as you go. A lot of the design work and high-level decisions end up going in to the specification, so by the time the implementation begins the hard and interesting choices have been made. That’s not to say it still isn’t fun at that point—even developing to a spec provides huge opportunities for simultaneous creativity and correctness in that unique programming way.
3.2. Getters and Setters
MP3 requires you to implement some simple getters and setters (just return or change the variable), and some ones with more complicated behavior. Be sure to read the documentation carefully.
3.3. Game Logic
You will need to do a bit of work to implement the game board. ConnectN is a Connect-4-like game. Tiles fall in the top (large Y values) and sit at the bottom. Just to confuse you a bit, we’ve reversed the coordinates from last week. So we’re now in the proper first quadrant of 2D space, with X values going left to right and Y values going down to up:
A ConnectN game ends when either player plays N consecutive tiles in either a single row or column 1. Tiles always have to be played at the lowest possible location in each column—in a real Connect-4 board they fall downward and rest on the tiles below them. Consult the Wikipedia page for more details.
3.4. Class Variables and Methods
Classes can define methods and variables that are not attached to instances.
Player.java for an example of a class variable used to provide each
instance with a unique ID.
You’ll need to implement some of these for
Be careful about varying definitions of equality.
You’ll need to implement
ConnectN.equals, but its definition of equality is
On the other hand, the class comparison methods use a different definition of
Passing all of the tests requires distinguishing between the two and
implementing each correctly.
MP3 is worth 100 points total, broken down as follows:
5 points for completing the title modifications
15 points total for completing the width, height, and N value getters and setters
10 points for completing the constructors
15 points for completing the get and set board functions
10 points for determining the game winner properly
10 points for calculating equality correctly
10 points for class static methods, including equality checks and factory creation methods
5 points for maintaining the game count and ID properly
10 points for no
10 points for submitting code that earns at least 40 points before Friday 2/16/2018 @ 5PM.
4.1. Test Cases
As in previous MPs, we have provided exhaustive test cases for each part of MP3. Please review the MP0 testing instructions.
5. Submitting Your Work
6. Academic Integrity
Please review the MP0 academic integrity guidelines.
Here’s how we’ll feel if we catch you cheating in CS 125: