Skip to content

Commit

Permalink
added cards
Browse files Browse the repository at this point in the history
  • Loading branch information
Patys committed Mar 6, 2017
1 parent 834be4f commit 86a665b
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
26 changes: 26 additions & 0 deletions core/src/com/patys/llgame/Card.java
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;
}
}
59 changes: 59 additions & 0 deletions core/src/com/patys/llgame/CardManager.java
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;
}
}

0 comments on commit 86a665b

Please sign in to comment.