Game - package sjm Project Simple Java [email protected] Laurens Van Keer | [email protected] 1.1 import java.awt.Color i import javax.swing

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
package sjm; /** * Project Simple Java Minesweeper * @author Laurens Van Keer | www.LaVaKe.be * @version 1.1 */ import java.awt.Color; import javax.swing.*; i /** * Game is part of the "Simple Java Minesweeper" (SJM) application. * * Game is the core of SJM. * All information of the current game is kept in this class. */ public class Game { p // player (name) private String player; p // "playing" indicates whether a game is running (true) or not (false). private boolean playing; p // The minefield private Minefield minefield; p // Difficulty settings private Difficulty difficulty; p // timer settings private Thread timer; private int timeLeft; p // Scores private String[][] lastScores; private int score; p /** * Game constructor * Initializes the application; not an actual new game. * * @param player */ public Game(String player) { // Set player name. setPlayer(player); s // Make sure a player has to press "new game" to start a new game. setPlaying(false); s // Create a new minefield. setMinefield( new Minefield( Difficulty.NORMAL.getNumberOfMines() ) ); s // Set default difficulty settings. setDifficulty( Difficulty.NORMAL ); setTimeLeft( Difficulty.NORMAL.getTimelimit() ); s
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
setLastScores(new String[4][2]); setScore(0); s // Reset the scores. resetScores(); r } /** * Game constructor for an anonymous player (startup of the app). */ public Game() { this(""); } /** * Sets the player name to player. * * @param player * @post Sets this.player to player. | new.getPlayer() == player */ public void setPlayer(String player) { this.player = player; } /** * Getter for the player attribute. * * @return The String player. */ public String getPlayer() { return player; } /** * Sets this.playing to true or false. * * @param playing * @post Sets this.playing to playing. | new.getPlaying() == playing */ public void setPlaying(boolean playing) { this.playing = playing; } /** * Getter for the playing attribute. * * @return true if this.playing is true; else false
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/25/2010 for the course CIS CIS3023 taught by Professor Seema during the Spring '10 term at Florida College.

Page1 / 8

Game - package sjm Project Simple Java [email protected] Laurens Van Keer | [email protected] 1.1 import java.awt.Color i import javax.swing

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online