Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- public class Questions {
- private ArrayList<QuestionsEntry> entries;
- public Questions() {
- entries = new ArrayList<QuestionsEntry>();
- }
- public void add( String Question, String Answer1, String Answer2, String Answer3, String Answer4, String corAnswer ) {
- entries.add(new QuestionsEntry(Question, Answer1, Answer2, Answer3, Answer4, corAnswer ));
- }
- public void remove (int index ) {
- entries.remove(index);
- }
- public QuestionsEntry get(int index) {
- return entries.get(index);
- }
- public int size() {
- return entries.size();
- }
- //PhoneBook.java given code
- public String toString( ) {
- StringBuffer temp = new StringBuffer();
- for (int i = 0; i < entries.size(); ++i) {
- temp.append( entries.get(i).toString() + "\n" );
- }
- return temp.toString();
- }
- }
- -----------------------------------------------------------------------------------------------
- class QuestionsEntry {
- private String Question;
- private String Answer1;
- private String Answer2;
- private String Answer3;
- private String Answer4;
- private String corAnswer;
- public QuestionsEntry( String inQuestion, String inAnswer1, String inAnswer2, String inAnswer3, String inAnswer4,
- String incorAnswer ) {
- Question = inQuestion;
- Answer1 = inAnswer1;
- Answer2 = inAnswer2;
- Answer3 = inAnswer3;
- Answer4 = inAnswer4;
- corAnswer = incorAnswer;
- }
- public String getQuestion() {
- return Question;
- }
- public String getAnswer1() {
- return Answer1;
- }
- public String getAnswer2() {
- return Answer2;
- }
- public String getAnswer3() {
- return Answer3;
- }
- public String getAnswer4(){
- return Answer4;
- }
- public String getcorAnswer(){
- return corAnswer;
- }
- public String toString(){
- return Question + ", " + Answer1 + ", " + Answer2 + ", " + Answer3 + ", " + Answer4 + ", " + corAnswer;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement