Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.92 KB | None | 0 0
  1. import java.util.ArrayList;
  2.  
  3. public class Questions {
  4.  
  5.     private ArrayList<QuestionsEntry> entries;
  6.  
  7.     public Questions() {
  8.         entries = new ArrayList<QuestionsEntry>();
  9.     }
  10.  
  11.     public void add( String Question, String Answer1, String Answer2, String Answer3, String Answer4, String corAnswer ) {
  12.         entries.add(new QuestionsEntry(Question, Answer1, Answer2, Answer3, Answer4, corAnswer ));
  13.     }
  14.  
  15.     public void remove (int index ) {
  16.         entries.remove(index);
  17.     }
  18.  
  19.     public QuestionsEntry get(int index) {
  20.         return entries.get(index);
  21.     }
  22.  
  23.     public int size() {
  24.         return entries.size();
  25.     }
  26.  
  27.     //PhoneBook.java given code
  28.     public String toString( ) {
  29.         StringBuffer temp = new StringBuffer();
  30.         for (int i = 0; i < entries.size(); ++i) {
  31.             temp.append( entries.get(i).toString() + "\n" );
  32.         }
  33.         return temp.toString();
  34.     }    
  35. }
  36.  
  37.  
  38.  
  39.  
  40.  
  41. -----------------------------------------------------------------------------------------------
  42.  
  43.  
  44. class QuestionsEntry {
  45.     private String Question;
  46.     private String Answer1;
  47.     private String Answer2;
  48.     private String Answer3;
  49.     private String Answer4;
  50.     private String corAnswer;
  51.  
  52.     public QuestionsEntry( String inQuestion, String inAnswer1, String inAnswer2, String inAnswer3, String inAnswer4,
  53.                            String incorAnswer ) {
  54.         Question = inQuestion;
  55.         Answer1 = inAnswer1;
  56.         Answer2 = inAnswer2;
  57.         Answer3 = inAnswer3;
  58.         Answer4 = inAnswer4;
  59.         corAnswer = incorAnswer;
  60.     }
  61.  
  62.     public String getQuestion() {
  63.         return Question;
  64.     }
  65.  
  66.     public String getAnswer1() {
  67.         return Answer1;
  68.     }
  69.  
  70.     public String getAnswer2() {
  71.         return Answer2;
  72.     }
  73.  
  74.     public String getAnswer3() {
  75.         return Answer3;
  76.     }
  77.  
  78.     public String getAnswer4(){
  79.         return Answer4;
  80.     }
  81.  
  82.     public String getcorAnswer(){
  83.         return corAnswer;
  84.     }
  85.  
  86.     public String toString(){
  87.         return Question + ", " + Answer1 + ", " + Answer2 + ", " + Answer3 + ", " + Answer4 + ", " + corAnswer;
  88.     }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement