I'm doing an assignment and I am confused as to what I have been asked to do. The specification is:
- Create a FlashCard class which takes 2 Strings in it's constructor, one for the question and one for the answer. The FlashCard should have a getQuestion and getAnswer method.
So they want me to create a constructor which takes two paramters, one for the question and one for the answer. And then they want me to create a getAnswer and getQuestion method which contains the answer and question for eah flashcard. But if the flashcard contains two strings then woudn't that mean that one flashcard has both the answer and question within it? Which would mean that I coudn't have a get answer and get question method as they cant be seperated?
import java.util.ArrayList;
public class FlashCard {
ArrayList<FlashCard> cardlist = new ArrayList<FlashCard>();
FlashCard(String question, String answer)
{
}
public ArrayList<FlashCard> getQuestion() {
cardlist.add(new FlashCard("1Q - By what initials was Franklin Roosevelt better known?", "1A - FDR"));
cardlist.add(new FlashCard("2Q - Which number president was Franklin Roosevelt?", "2A - 32"));
cardlist.add(new FlashCard("3Q - Which state was Franklin Roosevelt3 born in?", "3A - New York"));
cardlist.add(new FlashCard("4Q - In which year did Roosevelt become Governor of New York?", "4A - 1929"));
cardlist.add(new FlashCard("5Q - What was the name of Franklin Roosevelt's wife?", "5A - Elenor"));
cardlist.add(new FlashCard("6Q - How many children did Franklin Roosevelt have?", "6A - 6"));
cardlist.add(new FlashCard("7Q - From which university did Franklin Roosevelt graduate with an A.B in history?", "7A - Harvard"));
cardlist.add(new FlashCard("8Q - What was the first name of Franklin Roosevelt's 5th cousin, who was also President?", "8A - Theodore"));
cardlist.add(new FlashCard("9Q - Which disease is believed to be the causes of Franklin Roosevelt's paralysis?", "9A - Polio"));
cardlist.add(new FlashCard("10Q - At what age did Franklin Roosevelt die?", "10A - 63"));
}
public ArrayList<FlashCard> getAnswer() {
cardlist.add(new FlashCard("1Q - By what initials was Franklin Roosevelt better known?", "1A - FDR"));
cardlist.add(new FlashCard("2Q - Which number president was Franklin Roosevelt?", "2A - 32"));
cardlist.add(new FlashCard("3Q - Which state was Franklin Roosevelt3 born in?", "3A - New York"));
cardlist.add(new FlashCard("4Q - In which year did Roosevelt become Governor of New York?", "4A - 1929"));
cardlist.add(new FlashCard("5Q - What was the name of Franklin Roosevelt's wife?", "5A - Elenor"));
cardlist.add(new FlashCard("6Q - How many children did Franklin Roosevelt have?", "6A - 6"));
cardlist.add(new FlashCard("7Q - From which university did Franklin Roosevelt graduate with an A.B in history?", "7A - Harvard"));
cardlist.add(new FlashCard("8Q - What was the first name of Franklin Roosevelt's 5th cousin, who was also President?", "8A - Theodore"));
cardlist.add(new FlashCard("9Q - Which disease is believed to be the causes of Franklin Roosevelt's paralysis?", "9A - Polio"));
cardlist.add(new FlashCard("10Q - At what age did Franklin Roosevelt die?", "10A - 63"));
}
}
They also need to return ArrayList<FlashCard> so I'm really confused as to how I would structure this so that the getQuestions() method returns flashcard questions the same for the answers. Any help would be very much appreciated, thanks.
"cardlist.add(new FlashCard("1Q - By what initials was Franklin Roosevelt better known?", ""));be right forgetQuestionr()and the other way around for the answer?