Add JavaDocs and comments to the DailySudoku and DailySudokuColumns classes
This commit is contained in:
parent
a0e15e7508
commit
c57e753a26
2 changed files with 37 additions and 1 deletions
|
@ -8,7 +8,9 @@ import org.secuso.privacyfriendlysudoku.controller.database.model.DailySudoku;
|
||||||
import org.secuso.privacyfriendlysudoku.controller.database.model.Level;
|
import org.secuso.privacyfriendlysudoku.controller.database.model.Level;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines a database schema for saving daily sudokus
|
||||||
|
*/
|
||||||
public class DailySudokuColumns extends LevelColumns {
|
public class DailySudokuColumns extends LevelColumns {
|
||||||
|
|
||||||
public static final String TABLE_NAME = "ds_levels";
|
public static final String TABLE_NAME = "ds_levels";
|
||||||
|
@ -42,6 +44,11 @@ public class DailySudokuColumns extends LevelColumns {
|
||||||
"DROP TABLE IF EXISTS " + TABLE_NAME;
|
"DROP TABLE IF EXISTS " + TABLE_NAME;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new DailySudoku object using the data stored in a specific database row
|
||||||
|
* @param c the cursor pointing to the row whose data should be used
|
||||||
|
* @return the DailySudoku object created using the data from the database row
|
||||||
|
*/
|
||||||
public static DailySudoku getLevel(Cursor c) {
|
public static DailySudoku getLevel(Cursor c) {
|
||||||
Level level = LevelColumns.getLevel(c);
|
Level level = LevelColumns.getLevel(c);
|
||||||
int hintsUsed = c.getInt(c.getColumnIndexOrThrow(HINTS_USED));
|
int hintsUsed = c.getInt(c.getColumnIndexOrThrow(HINTS_USED));
|
||||||
|
@ -49,6 +56,11 @@ public class DailySudokuColumns extends LevelColumns {
|
||||||
return new DailySudoku(level.getId(), level.getDifficulty(), level.getGameType(), level.getPuzzle(), hintsUsed, timeNeeded);
|
return new DailySudoku(level.getId(), level.getDifficulty(), level.getGameType(), level.getPuzzle(), hintsUsed, timeNeeded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a specific DailySudoku instance, extracts all relevant parameters and saves them to a ContentValues object
|
||||||
|
* @param record the DailySudoku instance whose parameters should be extracted
|
||||||
|
* @return the ContentValues instance containing the extracted parameters
|
||||||
|
*/
|
||||||
public static ContentValues getValues(DailySudoku record) {
|
public static ContentValues getValues(DailySudoku record) {
|
||||||
ContentValues result = LevelColumns.getValues(record);
|
ContentValues result = LevelColumns.getValues(record);
|
||||||
result.put(HINTS_USED, record.getHintsUsed());
|
result.put(HINTS_USED, record.getHintsUsed());
|
||||||
|
|
|
@ -3,6 +3,9 @@ package org.secuso.privacyfriendlysudoku.controller.database.model;
|
||||||
import org.secuso.privacyfriendlysudoku.game.GameDifficulty;
|
import org.secuso.privacyfriendlysudoku.game.GameDifficulty;
|
||||||
import org.secuso.privacyfriendlysudoku.game.GameType;
|
import org.secuso.privacyfriendlysudoku.game.GameType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Models the content of a single row of the daily sudoku database
|
||||||
|
*/
|
||||||
public class DailySudoku extends Level {
|
public class DailySudoku extends Level {
|
||||||
private int hintsUsed;
|
private int hintsUsed;
|
||||||
private String timeNeeded;
|
private String timeNeeded;
|
||||||
|
@ -13,18 +16,35 @@ public class DailySudoku extends Level {
|
||||||
this.timeNeeded = timeNeeded;
|
this.timeNeeded = timeNeeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the amount of hints the user needed to solve this sudoku
|
||||||
|
* @return the amount of hints the user needed to solve this sudoku
|
||||||
|
*/
|
||||||
public int getHintsUsed() {
|
public int getHintsUsed() {
|
||||||
return hintsUsed;
|
return hintsUsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a new value for the hintsUsed attribute of this daily sudoku
|
||||||
|
* @param hintsUsed the new value for the hintsUsed attribute
|
||||||
|
*/
|
||||||
public void setHintsUsed(int hintsUsed) {
|
public void setHintsUsed(int hintsUsed) {
|
||||||
this.hintsUsed = hintsUsed;
|
this.hintsUsed = hintsUsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the time the user needed to solve this sudoku as a string
|
||||||
|
* @return the time the user needed to solve this sudoku as a string
|
||||||
|
*/
|
||||||
public String getTimeNeeded() {
|
public String getTimeNeeded() {
|
||||||
return timeNeeded;
|
return timeNeeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the time the user needed to solve this sudoku in seconds
|
||||||
|
* @return the time the user needed to solve this sudoku in seconds (or 0 if the timeNeeded parameter
|
||||||
|
* does not have the right format)
|
||||||
|
*/
|
||||||
public int getTimeNeededInSeconds() {
|
public int getTimeNeededInSeconds() {
|
||||||
if (timeNeeded.matches("/d/d:/d/d:/d/d")) {
|
if (timeNeeded.matches("/d/d:/d/d:/d/d")) {
|
||||||
String[] timeInstances = timeNeeded.split(":");
|
String[] timeInstances = timeNeeded.split(":");
|
||||||
|
@ -39,6 +59,10 @@ public class DailySudoku extends Level {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a new value for the timeNeeded attribute of this daily sudoku
|
||||||
|
* @param timeNeeded the new value for the timeNeeded attribute
|
||||||
|
*/
|
||||||
public void setTimeNeeded(String timeNeeded) {
|
public void setTimeNeeded(String timeNeeded) {
|
||||||
this.timeNeeded = timeNeeded;
|
this.timeNeeded = timeNeeded;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue