CS360 Assignment 5

Mastermind

 

Date Assigned: Thursday, April 1, 2004

Date Due: Tuesday, April 13, 2004

Total Points: 60

Introduction

 

For this assignment you are to write a Java server that implements the game mastermind. The server should accept connections from up to 10 clients at one time, and each client will play mastermind independently.

Goals

I will not be guiding you about what classes you will need to implement for this assignment.

This assignment will give you practical experience in:

-       Multithreaded programs

-       Writing servers and clients

-       Object oriented design

Assignment

Mastermind is played using six different coloured pegs that can be placed in any sequence and any combination in four holes in a row.

The object of the game

The server will randomly pick a sequence of 4 pegs each one being one of any of six colours.

 

It is the goal of the human player, using a client, to guess the correct combination of pegs in as few guesses as possible.

 

The server should end the game if the client doesnŐt guess the correct sequence of pegs after 8 tries. The server should also end the game if the user made the correct guess within 8 tries.

 

Each time the client guesses a combination the server should send a message indicating how many pegs were correct. The rules are:

-      For each of the pegs in the client guess that is the correct color and in the correct position, the server will display one small black peg to the right of that move. If the client scores 4 small black pegs on a guess, they have guessed the secret sequence.

 

-      For each of the pegs in the client guess that is a correct color in an incorrect position, the server will give the client one small white peg to the right of that move. Together, there will be no more than four small black and white pegs for each move.

 

The server should keep track of the highest score for each game. It should send a message to a client if they have scored better than the previous highest score.

GUI

It is possible to write this program as a command line game, however, because of the GUI capabilities of Java, you should be able to create a nice looking GUI for the game. You will lose points if you do not use a GUI.

Part 1

For next Tuesday the 6th of April, you should hand in a hard copy of your design. This should list the different classes that you will write including the main methods. You should make your program as modular as possible.

 

You should also familiarise yourself with the game. You can play a version of it online at: http://thinks.com/java/mastermind/mastermind.htm

Submitting your programs:

Save all your files in a folder called (your PUNET ID) and place the folder in the CS360 drop folder by 9.25 AM on the assignment due date. You do not need to submit the .class files. Just submit your .java files.