diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/database/columns/DailySudokuColumns.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/database/columns/DailySudokuColumns.java index 248371a..af4afe9 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/database/columns/DailySudokuColumns.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/database/columns/DailySudokuColumns.java @@ -8,7 +8,9 @@ import org.secuso.privacyfriendlysudoku.controller.database.model.DailySudoku; import org.secuso.privacyfriendlysudoku.controller.database.model.Level; - +/** + * Defines a database schema for saving daily sudokus + */ public class DailySudokuColumns extends LevelColumns { public static final String TABLE_NAME = "ds_levels"; @@ -42,6 +44,11 @@ public class DailySudokuColumns extends LevelColumns { "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) { Level level = LevelColumns.getLevel(c); 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); } + /** + * 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) { ContentValues result = LevelColumns.getValues(record); result.put(HINTS_USED, record.getHintsUsed()); diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/database/model/DailySudoku.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/database/model/DailySudoku.java index a78c660..9732a58 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/database/model/DailySudoku.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/database/model/DailySudoku.java @@ -3,6 +3,9 @@ package org.secuso.privacyfriendlysudoku.controller.database.model; import org.secuso.privacyfriendlysudoku.game.GameDifficulty; import org.secuso.privacyfriendlysudoku.game.GameType; +/** + * Models the content of a single row of the daily sudoku database + */ public class DailySudoku extends Level { private int hintsUsed; private String timeNeeded; @@ -13,18 +16,35 @@ public class DailySudoku extends Level { 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() { 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) { 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() { 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() { if (timeNeeded.matches("/d/d:/d/d:/d/d")) { String[] timeInstances = timeNeeded.split(":"); @@ -39,6 +59,10 @@ public class DailySudoku extends Level { 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) { this.timeNeeded = timeNeeded; }