Last active
October 4, 2019 07:53
-
-
Save AHaliq/7e90fa90ec77ca2189c4664024364ad4 to your computer and use it in GitHub Desktop.
Classes to model flashcards
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
abstract class CodeCard implements FlashCard { | |
protected String question; | |
protected String output; | |
public JavascriptCard(String q, String o) { | |
question = q; | |
output = o; | |
} | |
abstract render... | |
public JSONValue toJSON() { ... } | |
abstract Boolean evaluate(String code); | |
} |
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
class Deck { | |
ArrayList<FlashCard> cards; | |
public Deck(ArrayList<FlashCard> initialCards) { | |
cards = initialCards; | |
} | |
public Node renderListView() { | |
// render all cards in one box | |
} | |
public Node renderTileView() { | |
//render tile of deck summary | |
} | |
} |
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
interface FlashCard { | |
public JSONValue toJSON(); | |
public Node renderFront(); | |
public Node renderBack(); | |
public Boolean evaluate(String in); | |
} |
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
class FrontBackCard implements FlashCard { | |
protected String back; | |
protected String front; | |
public FrontBackCard(String f, String b) { | |
back = b; | |
front = f; | |
} | |
public Node renderFront() { | |
// creates javafx node and setup gui components | |
} | |
public Node renderBack() { | |
// like renderFront | |
} | |
public JSONValue toJSON() { | |
// my json class method calls | |
// create a json object and storing: | |
// type, front, back | |
} | |
public Boolean evaluate(String in) { | |
return in.equals(back); | |
} | |
} |
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
public JavascriptCard extends CodeCard { | |
public JavascriptCard(String f, String o) { | |
super(f, s); | |
} | |
...render and tojson... | |
public Boolean evaluate(String code) { | |
return TimothyUtil.evalJS(code).equals(output); | |
} | |
} |
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
public class Main | |
{ | |
public static void main(String[] args) { | |
FlashCard c = new FrontBackCard("Which year did the NASA first land on the moon", "1969"); | |
System.out.println(c.evaluate("1969")); \\ true | |
} | |
} |
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
class MultipleChoiceCard extends FrontBackCard { | |
protected ArrayList<String> choices; | |
public MultipleChoiceCard(String f, String b, ArrayList<String> c) { | |
super(f, b); | |
choices = c; | |
} | |
public override renderFront() { | |
// show choices as well | |
} | |
public override JSONValue toJSON() { | |
// store choices and different type name | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment