Project%201%20Information - PowerPoint PPT Presentation

About This Presentation
Title:

Project%201%20Information

Description:

Should be in the form: String Tokenizer Import java.util.StringTokenizer str = new StringTokenizer(line); Default delimiter is a space. – PowerPoint PPT presentation

Number of Views:105
Avg rating:3.0/5.0
Slides: 13
Provided by: barn76
Category:

less

Transcript and Presenter's Notes

Title: Project%201%20Information


1
Project 1 Information
  • CSCI-1302

2
Project Expectations
  • Not using OO principles in the first assignment
  • Will be done in a procedural fashion.
  • Global variables should to be static and placed
    outside of main().

3
File/Class Name
  • Your program should be named MineSweeper.java
  • This means you have to create a class also called
    MineSweeper in this file.
  • public class MineSweeper

4
Static Final Variables
  • Constants.
  • static final double PI 3.14
  • Should be declared in all CAPS
  • Declared outside of any function, but within the
    class declaration.
  • Can be used whenever possible
  • i.e. NUM_ROWS, NUM_COLS for matrix dimensions

5
The Minesweeper Board
  • The board should be a 10x10 matrix of integers.
  • int board new intNUM_ROWSNUM_COLS
  • Should store, COVERED, FLAGGED, or the integer
    representing of adjacent mines.

6
(No Transcript)
7
Reading User Input
  • Need to read commands from the User!
  • Should be in the form
  • ltu/fgt ltpos1gt ltpos2gt

8
(No Transcript)
9
String Tokenizer
  • Import java.util.StringTokenizer
  • str new StringTokenizer(line)
  • Default delimiter is a space.
  • Use str.countTokens() to ensure the right number
    of tokens have been passed in.
  • str.nextToken() returns next token as a string.

10
(No Transcript)
11
Random Numbers
  • Needed for randomizing your mine locations.
  • import java.util.Random
  • Random myRand new Random()
  • int pos myRand.nextInt(100)1

12
Check For
  • Invalid input (not U or F, not a valid mine
    location)
  • Invalid number of mines!
Write a Comment
User Comments (0)
About PowerShow.com