Introduction to Computers and Engineering Problem Solving Problem Set 8

advertisement

Introduction to Computers and Engineering Problem Solving

1.00 / 1.001 Fall 2005

Problem Set 8

Due: 11AM, Tuesday November 22, 2005 (We will not accept late submissions)

Soduko: Part 1 [100 points]

Introduction

In Problem Sets 8 and 9, you are going to implement the Soduko game. You will need to develop the GUI for the game as well as the strategy to play.

The Soduko game board consists of a grid of 9x9 cells. The grid is divided into 9 subgrids, each having 3x3 cells. The goal of the game is to populate the 81 cells with the numbers 1-9 according to the following rules:

-

-

each 9 cell row must have exactly 1 of each of the 9 numbers in it each 9 cell column must have exactly 1 of each of the 9 numbers in it each 9 cell sub-grid must have exactly 1 of each of the 9 numbers in it

For example, the following configuration is legal:

And the following configuration is illegal:

This is illegal for three reasons: there is more than one 9 in the second row, more than one 9 in the second column, and more than one 9 in the top left sub-grid. Any of these violations would make the solution invalid.

To get familiar with the game, you can play it at:

http://www.mousebreaker.com/games/sudoku/play.php

Your goal in this problem set is to design the application described above, based on the system requirements stated below. You will implement the design that you create here in

Problem Set 9.

NOTE:

For Problem Sets 8 and 9, you are strongly encouraged to collaborate with a single partner. If you choose to work with a partner, you will jointly submit a single assignment and both receive the same grade for it. You must work with the same partner for both problem sets 8 and 9. It is okay if you would prefer to work alone, but all the submissions will be held to the same grading criteria. You will not receive any additional credit for working alone.

System Requirements

Your application must be able to:

Allow users to play a graphical version of the Soduko game.

Allow users to create and save new Soduko game boards (you do not have to worry about designing the part that saves a game board until pset 9)

Allow users to load saved Soduko game boards (you do not have to worry about designing this part until pset 9)

Solve any arbitrary Soduko game board. You should determine how your program behaves if a board is unsolvable or illegal

Behave in an appropriate way if a game rule is violated

Behave in an appropriate way if a game board is unsolvable

1.00/1.001 2/4 Fall

Behave in an appropriate way if a user enters an invalid symbol in one of the cells of the puzzle. (You can expand the game to include symbols other than 1-9 ifyou want to, but make sure to specify the appropriate behavior.

We have split the design of this application into two phases: designing the user interface and designing the supporting Java classes.

Problem 1: User Interface Design [40 points]

Your solution to this problem will be a series of hand-drawn or computer-generated sketches.

Sketch 1 – Sketch the appearance of the initial state of your application

Sketch 2 – Sketch the appearance of the game after playing has begun.

Sketch 3 – Sketch the appearance of the game after a game is won.

Sketch 4 – Sketch the appearance of the game after a game is lost.

Sketch 5 – Sketch or describe all GUI components and what they will do.

There are many possible combinations of Swing components you can use to create your application. Your design will be graded based on how effectively your application meets the needs of users.

Problem 2: Class Design [60 points]

Your solution to this problem will be a list of Java classes that you will need to implement in your complete program. Since you are creating a design from scratch, you must place comments describing the role of each class you will use.

Also, for each class, you need to define data members and methods. At this point, you should leave the method implementation blank except for any required return value. For example, the method getBoardScore() might return an int , the score of the current board (which could just be how many cells are filled in). It should be specified in the class in which it appears as follows so that the class will compile and connections between classes can be checked: public int getBoardScore()

{ return 0; // value of 0 is a placeholder to be

// changed when method body is implemented

}

Please make sure to provide enough comments for each data member and method so that their role in the program is clear. Clear commenting is extremely important in this problem set.

1.00/1.001 3/4 Fall

Turn In Requirements for Problem Set 8

If you choose to work with a partner, you must include both of your names on your submission. If you have different TAs, be sure to write both TAs’ names.

Submit the problem set only once (either you or your partner can submit the assignment). Both you and your partner will get the same grade.

For problem 1, either submit the computer-generated sketches electronically or submit the hand-drawn sketches at the Tuesday, November 22 lecture.

For problem 2, submit Java files electronically. The same partner must turn in both the sketches and the Java files.

Turn In

Turn electronic copies of all source code ( .java

files). No printed copies are required except for the hand-drawn sketches.

Place comment with your full name, MIT server username, tutorial section, TA’s name (or names if you and your partner have different TAs), and assignment number at the beginning of all .java

files in your solution.

Remember . Points will be taken off for insufficient comments.

Place all of the files in your solution into a single zip file . Submit this single zip file under the appropriate section and problem set number.

Your solution is due at 11AM . Your uploaded files should have a time stamp of no later than 11AM on the due date.

Do not turn in compiled byte code ( .class

files) or backup source code

( .java~ files).

Penalties

No Credit If you turn in your problem set after 11AM on Tuesday

1.00/1.001 4/4 Fall

Download