|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.jhu.cs.oose.elevel.dataModel.Deck
public class Deck
Deck
represents the high-level intuition of a deck of flash cards.
The class stores a set of Card
s and set of TestStat
s based on past tests.
Constructor Summary | |
---|---|
Deck()
|
|
Deck(String name)
Initialize a basic Deck using the name provided |
Method Summary | |
---|---|
boolean |
addCard(Card c)
Add the specified Card to the Deck |
void |
addCardAtIndex(int i,
Card c)
Add the specified Card to the Deck at position i |
boolean |
addCards(List<Card> cards)
Add the list of cards to this deck |
boolean |
addTestStat(TestStat d)
Adds a new testing statistic to the current set of statistics for the deck |
void |
clearCards()
Removes all Card s from the Deck |
void |
clearTestStats()
Clears all of the statistics associated with this Deck |
boolean |
containsAllCards(Collection<Card> cards)
Returns true if this Deck contains all specified Card s |
boolean |
containsCard(Card c)
Returns true if this Deck contains the specified Card |
boolean |
equals(Deck other)
|
Card |
getCard(int index)
Returns the Card at the index of this deck |
List<Card> |
getCards()
Returns the Collection of Card s in this Deck |
String |
getDiskLocation()
Returns a String representing the location of this Deck on disk |
Card |
getFirstCard()
Helper method that returns the first card in the deck |
Card |
getLastCard()
Helper method that returns the last card in the deck |
String |
getName()
Returns a String representing the name of this Deck |
Collection<TestStat> |
getTestStatistics()
Returns a Collection of TestStat s representing the cumulative statistics of this deck |
boolean |
hasChanged()
|
int |
hashCode()
|
int |
indexOf(Card c)
Returns the index of the specified Card in the specified Deck |
boolean |
isDeckStatEmpty()
Returns true if there are no statistics |
int |
numCards()
Returns the number of cards in this deck |
int |
numDeckStatistics()
Returns the number of test statistics in this deck |
static Deck |
readFromDisk(String filepath)
Read a Deck from disk given an absolute file name |
boolean |
removeCard(Card c)
Removes the specified Card from the Deck , if it is present |
void |
setDiskLocation(String d)
Updates the location of this Deck on disk |
void |
setHasChanged(boolean b)
Sets the hasChanged flag to the specified boolean |
void |
setName(String n)
Updates the name of this Deck to the specified String |
void |
shuffle()
Randomizes the ordering of the cards in the card list, "shuffling" them |
Iterator<TestStat> |
testStatisticsIterator()
Returns an iterator over this Deck 's statistics |
String |
toString()
A String representation of the entire deck (including cards). |
void |
writeToDisk(String filepath)
Export the contents of this Deck to disk |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Deck()
public Deck(String name)
Deck
using the name provided
name
- A String representing the name of the Deck
Method Detail |
---|
public static Deck readFromDisk(String filepath) throws FileNotFoundException, IOException, ClassNotFoundException
Deck
from disk given an absolute file name
filepath
- A String
representing the absolute path file name of the file
Deck
created from the specified file
FileNotFoundException
IOException
ClassNotFoundException
public boolean addCard(Card c)
Card
to the Deck
c
- a Card
to be added to the deckpublic void addCardAtIndex(int i, Card c)
Card
to the Deck
at position i
i
- An int
representing the position at which to add the specified cardc
- The Card
to be addedpublic boolean addCards(List<Card> cards)
cards
- A List
of cards to add to this deck
true
if all cards were successfully added to the deck, false
otherwisepublic boolean addTestStat(TestStat d)
d
- TestStat
to be associated with the deck
true
if the TestStat
is inserted, false
otherwisepublic void clearCards()
Card
s from the Deck
Collection.clear()
public void clearTestStats()
Deck
Collection.clear()
public boolean containsAllCards(Collection<Card> cards)
true
if this Deck
contains all specified Card
s
cards
- A Collection to be checked for containment in this collection- See Also:
Collection.containsAll(Collection)
public boolean containsCard(Card c)
true
if this Deck
contains the specified Card
c
- the Card
whose presence in this Deck
is to be testedCollection.contains(Object)
public boolean equals(Deck other)
public Card getCard(int index)
Card
at the index of this deck
index
-
public List<Card> getCards()
Collection
of Card
s in this Deck
Collection
of Card
s in this Deck
public String getDiskLocation()
String
representing the location of this Deck
on disk
String
representing the location of this Deck
on diskpublic Card getFirstCard()
public Card getLastCard()
public String getName()
String
representing the name of this Deck
String
representing the name of this Deck
public Collection<TestStat> getTestStatistics()
Collection
of TestStat
s representing the cumulative statistics of this deck
Collection
of TestStat
s representing the cumulative statistics of this deckpublic boolean hasChanged()
public int hashCode()
hashCode
in class Object
public int indexOf(Card c)
Card
in the specified Deck
int
representing the index of the specified Card
in the specified
Deck
, -1 if the Card
is not contained in the specified Deck
public boolean isDeckStatEmpty()
true
if there are no statistics
true
if there are no statisticsCollection.isEmpty()
public int numCards()
public int numDeckStatistics()
Collection.size()
public boolean removeCard(Card c)
Card
from the Deck
, if it is present
c
- the Card
to be removed from the Deck
, if it is presentCollection.remove(Object)
public void setDiskLocation(String d)
Deck
on disk
d
- a String
representing the new location of this Deck
on diskpublic void setHasChanged(boolean b)
boolean
b
- the boolean
to update the flag topublic void setName(String n)
Deck
to the specified String
n
- a String
representing the new name of this Deck
public void shuffle()
public Iterator<TestStat> testStatisticsIterator()
Deck
's statistics
TestStat
s of this Deck
Collection.iterator()
public String toString()
String
representation of the entire deck (including cards).
toString
in class Object
public void writeToDisk(String filepath) throws IOException
Deck
to disk
filepath
- A String
representing the absolute path file name of the file
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |