|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.eriksilkensen.sudoku.SudokuControl
public class SudokuControl
SudokuControl is the Control component in the M-V-C framework and so behaves like one would expect of a Control
It coordinates all communication between the Model and the View, and is used to start a new game.
| Field Summary | |
|---|---|
protected SudokuModel |
model
|
protected SudokuView |
view
|
| Constructor Summary | |
|---|---|
SudokuControl()
Default no-arg constructor for the Control It probably will never be used |
|
SudokuControl(SudokuModel model)
Initializes the Control with its passed in Model and then creates the View. |
|
| Method Summary | |
|---|---|
void |
checkBoard()
Checks the user's Board |
void |
checkForBestTimes()
Uses the Model to checkForBestTimes() |
void |
clear()
Clears the Model |
void |
clearTimes()
Clears the Model's Best Times |
boolean |
connectToNetwork(java.lang.String name)
This Control doesn't concern itself with Network capabilities, but it still defines the methods that could be used by one that does. |
boolean |
disconnectFromNetwork()
This Control doesn't concern itself with Network capabilities, but it still defines the methods that could be used by one that does. |
java.util.ArrayList<BestTime> |
getBestTimes()
Returns a List of the top 5 Best Times |
Board |
getBoard()
Returns the current Board in use by the Model |
int |
getBoardID()
Returns the current Board's ID |
BoardDifficulties |
getDifficulty()
Returns the current difficulty of the Model |
protected java.lang.String |
getHost()
|
int |
getIDLimit()
Used to get the limit for possible Board IDs that could be played as an integer. |
protected int |
getPort()
|
java.lang.String |
getRange()
Used to get the range of possible Board IDs that the user could choose from when manually selecting a Board |
Board |
getSolution()
Returns the solution to the current Board in use by the Model |
int |
getStatus()
Returns the current status of the Model |
void |
giveUp()
Notifies the Model that the user has decided to Give Up |
void |
hint()
Called by the View when a user is requesting a Hint |
protected void |
initGame()
Initializes a game by setting up the View's controls |
boolean |
isLegalID(int ID)
Helper method to determine if the requested ID does in fact exist |
void |
loadGame(java.io.File file)
Loads a game from the selected File |
boolean |
newBoard()
The no-arg version of newBoard() assumes the user is asking to enter a specific ID, so the Control gets it and passes it on to the Model If the user decides to not enter an ID, newBoard() returns false. |
void |
newBoard(BoardDifficulties difficulty)
A View requests a new Board at the given difficulty, so the Model gets one and the Control starts it |
void |
newBoard(int ID)
This method should only be used by the NetworkedControl in order to start a new game by passing along messages over the network. |
void |
newDownloadedBoard()
This version of newBoard() downloads a Board from the internet at a random difficulty level. |
void |
printBoard()
Prints the current Board |
void |
printSolution()
Prints the current Solution |
void |
registerObserver(SudokuObserver observer)
This Control isn't actually Observable, but it still passes along the View's request to register as an Observer with the Observable Model |
void |
removeObserver(SudokuObserver observer)
Passes the View's request to remove itself from the Model's list of Observers |
void |
saveGame(java.io.File file)
Saves a game to the specified File |
boolean |
setBoard(int row,
int col,
int playerValue)
When a user places a number on the board, the Model is updated by sending the location and value of the Cell that the user placed. |
protected void |
setHost(java.lang.String host)
|
protected void |
setPort(java.lang.String port)
|
void |
setStatusIdle()
Sets the status of the Model to be IDLE |
void |
setStatusPlaying()
Sets the status of the Model to be PLAYING |
void |
setTime(int time)
Sets the time |
protected void |
showHideChatRoom()
|
void |
start()
start() should be called from a launching (main) method in order to, right now, just show the View |
void |
submitTimes()
|
void |
windowClosing()
Called by the View when the user is closing its Window, so the Control can do whatever last-second things it needs to before shutting down. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected SudokuModel model
protected SudokuView view
| Constructor Detail |
|---|
public SudokuControl()
public SudokuControl(SudokuModel model)
| Method Detail |
|---|
public void registerObserver(SudokuObserver observer)
public void removeObserver(SudokuObserver observer)
public void start()
public void newBoard(BoardDifficulties difficulty)
public boolean newBoard()
public void saveGame(java.io.File file)
throws java.io.IOException
java.io.IOException
public void loadGame(java.io.File file)
throws java.io.IOException,
java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundExceptionpublic void newDownloadedBoard()
public void newBoard(int ID)
protected void setHost(java.lang.String host)
protected void setPort(java.lang.String port)
protected java.lang.String getHost()
protected int getPort()
protected void showHideChatRoom()
protected void initGame()
public void hint()
public boolean setBoard(int row,
int col,
int playerValue)
public void clear()
public void clearTimes()
public void submitTimes()
throws java.net.MalformedURLException,
com.jcraft.jsch.JSchException,
java.io.IOException
java.net.MalformedURLException
com.jcraft.jsch.JSchException
java.io.IOExceptionpublic void checkBoard()
public void giveUp()
public void checkForBestTimes()
public void setStatusIdle()
public void setStatusPlaying()
public int getStatus()
public BoardDifficulties getDifficulty()
public int getBoardID()
public void setTime(int time)
public java.lang.String getRange()
public int getIDLimit()
public boolean isLegalID(int ID)
public java.util.ArrayList<BestTime> getBestTimes()
public Board getBoard()
public Board getSolution()
public void windowClosing()
public boolean connectToNetwork(java.lang.String name)
public boolean disconnectFromNetwork()
public void printBoard()
throws java.lang.Exception
java.lang.Exception
public void printSolution()
throws java.lang.Exception
java.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||