Android Open Source - SeniorDesign Found Set Record






From Project

Back to project page SeniorDesign.

License

The source code is released under:

GNU General Public License

If you think the Android project SeniorDesign listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package fakesetgame.seniordesign.data;
//from   ww  w. ja  va 2  s .c  o  m
import android.database.Cursor;
import android.provider.BaseColumns;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import fakesetgame.seniordesign.model.Tile;

/**
 * A class to hold information retrieved from the database about sets found during a game.
 */
public class FoundSetRecord {
    private final long _id;
    private final Set<Tile> tileSet;
    private final long totalElapsed;
    private final long deltaElapsed;
    private final boolean hintProvided;

    public Set<Tile> getTileSet() {
        return tileSet;
    }

    public long getId() {
        return _id;
    }

    public long getTotalElapsed() {
        return totalElapsed;
    }

    public long getDeltaElapsed() {
        return deltaElapsed;
    }

    public boolean wasHintProvided() {
        return hintProvided;
    }

    private FoundSetRecord(long _id, Collection<Tile> tileSet, long totalElapsed, long deltaElapsed, boolean hintProvided) {
        this._id = _id;
        this.tileSet = new HashSet<Tile>(tileSet);
        this.totalElapsed = totalElapsed;
        this.deltaElapsed = deltaElapsed;
        this.hintProvided = hintProvided;
    }

    public static FoundSetRecord fromCursor(Cursor c) {

        String tilesString = c.getString(c.getColumnIndexOrThrow(TableDef.COLUMN_NAME_TILES));
        String[] tilesStrings = tilesString.split(",");
        Tile[] tiles = new Tile[tilesStrings.length];
        for (int i = 0; i < tiles.length; i++)
            tiles[i] = Tile.fromString(tilesStrings[i]);


        return new FoundSetRecord(
                c.getLong(c.getColumnIndexOrThrow(TableDef._ID)),
                Arrays.asList(tiles),
                c.getLong(c.getColumnIndexOrThrow(TableDef.COLUMN_NAME_ELAPSED)),
                c.getLong(c.getColumnIndexOrThrow(TableDef.COLUMN_NAME_DELTA)),
                c.getInt(c.getColumnIndexOrThrow(TableDef.COLUMN_NAME_HINT)) == 1
        );
    }

    /**
     * Defines the found set table
     */
    public static abstract class TableDef implements BaseColumns {

        public static final String TABLE_NAME = "found_sets";

        public static final String COLUMN_NAME_OUTCOME = "outcome_id";
        public static final String COLUMN_NAME_TILES = "tiles";
        public static final String COLUMN_NAME_ELAPSED = "elapsed";
        public static final String COLUMN_NAME_DELTA = "delta";
        public static final String COLUMN_NAME_HINT = "hint";
        public static final String COLUMN_NAME_INSERTED = "inserted";

        public static final String[] ALL_COLUMNS = {
                TableDef._ID,
                TableDef.COLUMN_NAME_OUTCOME,
                TableDef.COLUMN_NAME_TILES,
                TableDef.COLUMN_NAME_ELAPSED,
                TableDef.COLUMN_NAME_DELTA,
                TableDef.COLUMN_NAME_HINT,
                TableDef.COLUMN_NAME_INSERTED,
        };
    }
}




Java Source Code List

fakesetgame.seniordesign.BoardTest.java
fakesetgame.seniordesign.GameScreen.java
fakesetgame.seniordesign.GameTest.java
fakesetgame.seniordesign.HomeScreen.java
fakesetgame.seniordesign.OptionsScreen.java
fakesetgame.seniordesign.SettingsTest.java
fakesetgame.seniordesign.SplashScreen.java
fakesetgame.seniordesign.SummaryScreen.java
fakesetgame.seniordesign.TileSetTest.java
fakesetgame.seniordesign.data.FoundSetRecord.java
fakesetgame.seniordesign.data.GameOutcome.java
fakesetgame.seniordesign.data.GameSummaryListItemCursorAdapter.java
fakesetgame.seniordesign.data.OptionsHelper.java
fakesetgame.seniordesign.data.PlayerDataDbHelper.java
fakesetgame.seniordesign.data.Setting.java
fakesetgame.seniordesign.data.package-info.java
fakesetgame.seniordesign.model.BoardSize.java
fakesetgame.seniordesign.model.Board.java
fakesetgame.seniordesign.model.Color.java
fakesetgame.seniordesign.model.GameOverEvent.java
fakesetgame.seniordesign.model.GameOverListener.java
fakesetgame.seniordesign.model.Game.java
fakesetgame.seniordesign.model.HintProvider.java
fakesetgame.seniordesign.model.Modifier.java
fakesetgame.seniordesign.model.Shading.java
fakesetgame.seniordesign.model.Shape.java
fakesetgame.seniordesign.model.TileSet.java
fakesetgame.seniordesign.model.Tile.java
fakesetgame.seniordesign.model.package-info.java
fakesetgame.seniordesign.view.GameSummaryListItemView.java
fakesetgame.seniordesign.view.ShadedImageView.java
fakesetgame.seniordesign.view.package-info.java
fakesetgame.seniordesign.package-info.java