-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTile.java
More file actions
87 lines (70 loc) · 2.32 KB
/
Tile.java
File metadata and controls
87 lines (70 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*--------------------------------------------------------------
-SUB-TO-WARRIORPUG-ON-YT-
File: MineSweeperApp.java
Date: 2/17/23
Purpose: A tile class to be put into a 2D array for my minesweeper game
Author: ALosee315
Sauce Code: 8
----------------------------------------------------------------*/
public class Tile{
private boolean isFlagged; //Is tile flagged
private boolean isRevealed; //Is tile revealed
private boolean isFirst; //Is the tile the first clicked, or around the first tile clicked
private int numMines; //-1 if is mine
//Constructor------------------------------------------------------
public Tile(){
numMines = 0;
isRevealed = false;
isFlagged = false;
isFirst = false;
}
//Accessors-----------------------------------------------------------------------------
public boolean getMineStatus(){ //Returns true if the tile is a mine, false if it isn't
if(numMines == -1){
return true;
}else{
return false;
}
}
public int getMineNum(){ //Returns true if the tile is a mine, false if it isn't
return numMines;
}
//Returns true if these booleans are true
public boolean getRevealed(){
return isRevealed;
}
public boolean getFlagged(){
return isFlagged;
}
public boolean getFirst(){
return isFirst;
}
//Mutators---------------------------------------------------------------------------
public void setFirst(){ //First Tile Clicked
isFirst = true;
}
public void setRevealed(){ //Tile Revealed
isRevealed = true;
}
public void setFlagged(){ //Tile flagged
isFlagged = true;
}
public void toggleFlagged(){ //Flagged = !Flagged
isFlagged = !isFlagged;
}
public void reset(){ //Set tile to starting state
numMines = 0;
isRevealed = false;
isFlagged = false;
isFirst = false;
}
public void incMineNum(){ //Increment number of mines around the tile
numMines++;
}
public void setMine(){ //sets the tile to a mine tile
numMines = -1;
}
public void setMineNum(int num){ //Set the number of mines around a tile
numMines = num;
}
}