Skip to content
Permalink
Browse files

added cards

  • Loading branch information...
Patys committed Mar 6, 2017
1 parent 834be4f commit 86a665b29c49186ce646a3cb7b6991d97c1fe5f2
Showing with 85 additions and 0 deletions.
  1. +26 −0 core/src/com/patys/llgame/Card.java
  2. +59 −0 core/src/com/patys/llgame/CardManager.java
@@ -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;
}
}
@@ -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.
You can’t perform that action at this time.