-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuestion.java
More file actions
51 lines (46 loc) · 1.4 KB
/
Question.java
File metadata and controls
51 lines (46 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.util.ArrayList;
public abstract class Question{
public String prompt;
public ArrayList<String> choices = new ArrayList<>();
protected boolean multiChoice;
//default constructor
public Question(String prompt){
this.prompt = prompt;
}
// set choices for question
public void setChoices(){
// METHOD FOR ALLOWING USER TO INPUT CHOICES< NOT USING DURING SIMULATION PROCESS
/*
Scanner sc = new Scanner(System.in);
System.out.println("Enter each choice for the question, end the process by entering nothing...");
while(true){
System.out.print("Option: ");
String input = sc.nextLine();
if(input.equals("")){
break;
}
choices.add(input);
}
*/
choices.add("Red");
choices.add("Blue");
choices.add("Green");
choices.add("Orange");
}
// get the choices
public ArrayList<String> getChoices(){
return choices;
}
// return if multichoice question
public boolean isMultiChoice(){
return multiChoice;
}
//tostring method
public String toString(){
String displayChoices = "";
for(int i = 0; i < choices.size(); i++){
displayChoices += i + 1 + ". " + choices.get(i) + "\n";
}
return "\nQ: " + prompt + "\n" + displayChoices;
}
}