-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssign.java
More file actions
91 lines (77 loc) · 2.55 KB
/
Assign.java
File metadata and controls
91 lines (77 loc) · 2.55 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
88
89
90
91
/**
* Assign
* This class handles the creation of all moves in the game
* It stores the row and column of the move, and the state of the slot being assigned
* Assigns each move the game based on row and columns
*
*
* @author Lauren Scott
* @author Arun Kumar Sekar
*
* @version Janurary 2024
*/
public class Assign {
private int col, row;//The row and column being assigned
private Sudoku game;//The game
Slot[][] moves;//2D Array to store the game's moves
private String prevState; // To store the previous state of the slot
private String number; // To store the number for the move
/**
* Constructor for Assign class.
* This gets the total number of moves and calls methods to determine the row that will be filled, and to set the state of the slot being assigned.
* @param game - the game
* @param col - the column the user has selected
* @param player - a Boolean value that determines whether it is a player/computer move
*/
public Assign(Sudoku game, int row, int col, String number, String prevState) {
this.game = game;
this.col = col;
this.row = row;
this.moves = game.getMoves();
this.prevState = prevState;
this.number = number; // Store the number
assignMove(number);
}
/**
* assignMove
* This method assigns the move to the game
* @param player a Boolean value to determine whether it is a computer/player move
*/
public void assignMove(String number) {
moves[row][col].setState(number);
}
/**
* getRow
* This method returns the current row value for this move. It allows another element of the program to access this move's current row.
* @return the row value
*/
public int getRow() {
return row;
}
/**
* getCol
* This method returns the current col value for this move. It allows another element of the program to access this move's current col.
* @return the Col value
*/
public int getCol() {
return col;
}
/**
* getPrevMove
* This method returns the previous state of the slot to perform the undo operation
*
* @return previous value of the slot
*/
public String getPrevMove() {
return prevState;
}
/**
* getNumber
* This method returns the latest iput number to perform the redo operation
*
* @return latest value of the slot
*/
public String getNumber() {
return number;
}
}//End of class Assign