-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,26 @@ | |||
package com.patys.llgame; | |||
|
|||
public class Card { | |||
// good or wrong picks | |||
public float good; | |||
public float wrong; | |||
|
|||
public String word; | |||
public String meaning; | |||
|
|||
public Card(String word, String meaning) { | |||
this.good = 0; | |||
this.wrong = 0; | |||
|
|||
this.word = word; | |||
this.meaning = meaning; | |||
} | |||
|
|||
public Card(String word, String meaning, float good, float wrong) { | |||
this.good = good; | |||
this.wrong = wrong; | |||
|
|||
this.word = word; | |||
this.meaning = meaning; | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,59 @@ | |||
package com.patys.llgame; | |||
|
|||
import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.Random; | |||
|
|||
public class CardManager { | |||
private List<Card> cards; | |||
|
|||
public CardManager() { | |||
cards = new ArrayList<Card>(); | |||
} | |||
|
|||
Boolean addNewCard(String word, String meaning) { | |||
if(cards.add(new Card(word, meaning))) | |||
return true; | |||
else | |||
return false; | |||
} | |||
|
|||
Card getCardByWord(String word) { | |||
for(int i = 0; i < cards.size(); i++) { | |||
if(cards.get(i).word.contentEquals(word)) | |||
return cards.get(i); | |||
} | |||
return null; | |||
} | |||
|
|||
Card getCardByMeaning(String meaning) { | |||
for(int i = 0; i < cards.size(); i++) { | |||
if(cards.get(i).meaning.contentEquals(meaning)) | |||
return cards.get(i); | |||
} | |||
return null; | |||
} | |||
|
|||
Card getRandomCard() { | |||
Random rand = new Random(); | |||
int n = rand.nextInt(cards.size()-1); | |||
return cards.get(n); | |||
} | |||
|
|||
Boolean loadCards(String filename) { | |||
// TODO: read all cards from file | |||
|
|||
|
|||
return true; | |||
} | |||
|
|||
Boolean saveCards(String filename) { | |||
// TODO: save all cards from list: cards | |||
|
|||
return true; | |||
} | |||
|
|||
public List<Card> getCards() { | |||
return cards; | |||
} | |||
} |