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 new file mode 100644 index 0000000..0c342d8 --- /dev/null +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/database/columns/DailySudokuColumns.java @@ -0,0 +1,57 @@ +package org.secuso.privacyfriendlysudoku.controller.database.columns; + +import android.content.ContentValues; +import android.database.Cursor; +import android.provider.BaseColumns; + +import org.secuso.privacyfriendlysudoku.controller.database.model.DailySudoku; +import org.secuso.privacyfriendlysudoku.controller.database.model.Level; + + + +public class DailySudokuColumns extends LevelColumns { + + public static final String TABLE_NAME = "ds_levels"; + + public static final String HINTS_USED = "ds_hints_used"; + public static final String TIME_NEEDED = "ds_time_needed"; + public static final String[] PROJECTION = { + _ID, + DIFFICULTY, + GAMETYPE, + PUZZLE, + HINTS_USED, + TIME_NEEDED + }; + + private static final String TEXT_TYPE = " TEXT "; + private static final String INTEGER_TYPE = " INTEGER "; + private static final String TIME_TYPE = " TIME (0) "; + private static final String COMMA_SEP = ","; + + public static String SQL_CREATE_ENTRIES = + "CREATE TABLE " + TABLE_NAME + " (" + + _ID + INTEGER_TYPE + " PRIMARY KEY" + COMMA_SEP + + DIFFICULTY + TEXT_TYPE + COMMA_SEP + + GAMETYPE + TEXT_TYPE + COMMA_SEP + + PUZZLE + TEXT_TYPE + COMMA_SEP + + HINTS_USED + INTEGER_TYPE + COMMA_SEP + + TIME_NEEDED + TIME_TYPE + " )"; + + + public static DailySudoku getLevel(Cursor c) { + Level level = LevelColumns.getLevel(c); + int hintsUsed = c.getInt(c.getColumnIndexOrThrow(HINTS_USED)); + String timeNeeded = c.getString(c.getColumnIndexOrThrow(TIME_NEEDED)); + return new DailySudoku(level.getId(), level.getDifficulty(), level.getGameType(), level.getPuzzle(), hintsUsed, timeNeeded); + } + + public static ContentValues getValues(DailySudoku record) { + ContentValues result = LevelColumns.getValues(record); + result.put(HINTS_USED, record.getHintsUsed()); + result.put(TIME_NEEDED, record.getTimeNeeded()); + + return result; + } + +} 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 new file mode 100644 index 0000000..f8546c3 --- /dev/null +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/database/model/DailySudoku.java @@ -0,0 +1,31 @@ +package org.secuso.privacyfriendlysudoku.controller.database.model; + +import org.secuso.privacyfriendlysudoku.game.GameDifficulty; +import org.secuso.privacyfriendlysudoku.game.GameType; + +public class DailySudoku extends Level { + private int hintsUsed; + private String timeNeeded; + + public DailySudoku(int id, GameDifficulty gameDifficulty, GameType gameType, int[] puzzle, int hintsUsed, String timeNeeded) { + super(id, gameDifficulty, gameType, puzzle); + this.hintsUsed = hintsUsed; + this.timeNeeded = timeNeeded; + } + + public int getHintsUsed() { + return hintsUsed; + } + + public void setHintsUsed(int hintsUsed) { + this.hintsUsed = hintsUsed; + } + + public String getTimeNeeded() { + return timeNeeded; + } + + public void setTimeNeeded(String timeNeeded) { + this.timeNeeded = timeNeeded; + } +}