MP3: ConnectN

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:

  1. design a class that meets a given specification

  2. implement that class including both properly-protected variables and appropriate methods

We’ll also continue to reinforce the learning objectives from MP0, MP1, and MP2.

2. Assignment Structure

MP3 consists of a simple client-server system. The HTML, CSS, and JavaScript for the client are provided for you. But it relies on your backend to work properly.

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 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

Use this GitHub Classroom invitation link to fork your copy of MP3. Once your repository has been created, import it into IntelliJ following our assignment Git workflow guide.

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:

  1. Run as a Java application. You’ll need to at least create and get a few things working before the web server will run at all.

  2. Open your web browser and navigate to http://localhost:8126.

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:

(0, 2)

(1, 2)

(2, 2)

(0, 1)

(1, 1)

(2, 1)

(0, 0)

(1, 0)

(2, 0)

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. See 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

3.5. Equality

Be careful about varying definitions of equality. You’ll need to implement ConnectN.equals, but its definition of equality is quite strict. On the other hand, the class comparison methods use a different definition of equality. Passing all of the tests requires distinguishing between the two and implementing each correctly.

3.6. Getting Help

The course staff is ready and willing to help you every step of the way! Please come to office hours, or post on the forum when you need help. You should also feel free to help each other, as long as you do not violate the academic integrity requirements.

4. Grading

MP3 is worth 100 points total, broken down as follows:

  1. 80 points:

    • 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

  2. 10 points for no checkstyle violations

  3. 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.

4.2. Autograding

Like MP0 and MP1, we have provided you with an autograding script that you can use to estimate your current grade as often as you want. Please review the MP0 autograding instructions.

5. Submitting Your Work

Follow the instructions from the submitting portion of the CS 125 workflow instructions.

And remember, you must submit something that earns 40 points before Friday 2/16/2018 @ 5PM to earn 10 points on the assignment.

6. Academic Integrity

Here’s how we’ll feel if we catch you cheating in CS 125:

CS 125 is now CS 124

This site is no longer maintained, may contain incorrect information, and may not function properly.

Created 10/24/2021
Updated 10/24/2021
Commit a44ff35 // History // View
Built 10/24/2021 @ 21:29 EDT