

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Professor: Yang; Class: GRAPHICS AND MULTIMEDIA; Subject: Computer Science; University: University of Kentucky; Term: Fall 2009;
Typology: Assignments
1 / 3
This page cannot be seen from the preview
Don't miss anything!


In this project, you are asked to implement a popular game MineSweeper using JAVA.
Minesweeper is a Windows Games appeared since Windows 95. The object of Minesweeper is to locate all the mines as quickly as possible without uncovering any of them. As shown in the figure, the game area consists of the playing field, a mine counter (left red text) and a timer (right red text). One can uncover a square by clicking it. If one uncovers the mine, the game is lost.
If a number appears on a square, it indicates how many mines are in the eight squares that surround the numbered one.
To mark a square you suspect contains a mine, right-click it.
This is a non-trivial programming assignment. It has two major components. The first component is the design and implementation of the graphical user interface and the second component is to implement the underlying game logic.
Part I – User Interface The user interface should be similar to the official mine sweeper. In particular, it should contain a pull-down menu, the restart button (the smiley), the play field, the mine counter, and the timer. The timer and the counter can be presented with simple JLabel, but the playfield should be all graphical. When designing the user interface it should be kept in mind that the size of the play field is user configurable.
Functional Requirement:
Each square can have the following attributes, which should be displayed graphically as an icon o On (covered) or off (uncovered) o how many neighboring mine for an uncovered mine o has mine or not Each square should respond to mouse click by displaying sequentially any of the possible icons.
Size change, timer, and counter can be changed via command line argument; they will remain fixed during the execution. The restart button can be text-based. User can start and quit the program via the pull-down menu or other standard ways of closing a window. Extra credit (15 pts), the more you can mimic the look and feel of the original minesweep, the higher extra credit you can own – up to 15 pts.
Hint:
Define a class for each square in the playfield; Each square in the playfield should be implemented as a JButton; Use an array to store all the squares.
Part II– User Interaction and Game Logic In this part, you will implement functions to populate the playfield and provide all the necessary user interactions to mimic the original minesweep as much as possible. More specifically they are:
Implement a random function to populate the game playfield, reset the game counter and mine counter. Start/restart the game For each square, respond to left mouse click. If the current square is a mine, game over. If the current square has a neighbor mine counter of zero, recursively open up squares until it reaches a non-zero square or play field boundary (as in the real minesweeper) For each square, respond to right mouse click by marking the current square as a miner and change the mine counter accordingly, or unmark if already marked. Provide user-selectable playfield size (which corresponds to difficulty) Implement the game clock (timer) Extra credit (15 pts) right and left click at the same time on an uncovered square to open up its neighbor if the number of marked mine in its neighbor is the same as its neighbor mine number. Note that in case of wrong marking, this round should end (user loses) because a mine is uncovered.
If you are ever confused about the function, run winmine on a windows XP box!
Submission and Grading You will need to demonstrate your program to Dr. Yang. Details will be announced in class on 10/6/2009. A standard grade sheet will be used to determine your score. You are also required to submit all the java source code in a zip file in the end of your session. Your source code should include a brief readme file explaining the file/class structure, in particular the entry point