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 MP5 you’ll be learning Java class design and object-oriented programming as you complete a simple Connect-4-like game. It is due Friday, November 3rd, 2017 @ 5PM. To receive full credit, you must submit by this deadline. In addition, 10% of your grade on MP5 is for committing code that earns at least 50 points by Monday, October 30th, 2017 @ 5PM.
1. Learning Objectives
The purpose of MP5 is begin introducing you to object-oriented programming. MP5 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
MP5 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 MP5, the official specification is our
MP5 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 MP5
Please follow the instructions from MP1.
You’ll find MP5 in an
MP5 folder in your Subversion home directory.
Unless you want to learn a lot more about Subversion, do not delete your MP5
server folder once you have it.
This is something that you cannot fix on your own using the Eclipse Subversive
Subversion plugin, and will need to get course staff help with.
2.2. Your Goal
At this point you should be familiar with the requirements from previous MPs. MP5 is similar, and retains (but strengthens) the starting the assignment on time grading component from MP3 and MP4. See the grading description below.
2.3. Running MP5
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 probably should as well.
2.3.1. Fixing port conflict problems
Follow the instructions from MP4.
3. Approaching MP5
Unlike MP4, MP5 is not a lot of code to write. But here are the bits that are likely to trip you up.
3.1. Read the Fine Manual
To complete MP5 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.
Make sure that your class has private and public variables as specified.
Checkstyle will normally complain about public instance variables.
To get it to shut up and get your 10 points, you can add
@SuppressWarnings("checkstyle:visibilitymodifier") above the variable that is
causing you problems.
3.3. Getters and Setters
MP5 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.4. 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.5. 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.
3.7. 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.
MP5 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 committing code that earns at least 50 points before Monday, October 30th, 2017 @ 5PM.
4.1. Test Cases
As in previous MPs, we have provided exhaustive test cases for each part of MP5. Please review the MP1 testing instructions.
Like previous assignments, we provide you with an autograding script that you can use to estimate your current grade as often as you want. Note that, like MP3 and MP4, the local autograder can only calculate 90 out of your 100 total points.
Unless you have modified the test cases or autograder configuration files, the autograding output should equal the score that you will earn when you submit. If you modify our test cases or the autograding configuration, all bets are off.
5. Submitting Your Work
Overall you should refer to our instructions for using Subversion. Commit early and often! You only earn credit for the version of your code that is committed to your repository, so ensure that we have your best submission before the deadline.
And remember, you must commit something that earns 50 points before Monday, October 30th, 2017 @ 5PM to earn 10 points on the assignment. This is a bit of a higher bar than in previous assignments, since fixing checkstyle errors will only get you 10 points and there are no points for just compiling. So you’ll need to complete a few bits of class logic past this bar.
5.1. Academic Integrity
Please review the MP1 academic integrity guidelines.