Skip to content

Instantly share code, notes, and snippets.

@AnEmortalKid
Created March 20, 2016 20:44
Show Gist options
  • Save AnEmortalKid/d7484cbc1129f9f06c2e to your computer and use it in GitHub Desktop.
Save AnEmortalKid/d7484cbc1129f9f06c2e to your computer and use it in GitHub Desktop.
public class Question {
private String question;
private String correctAnswer;
private String[] answerOptions;
public Question(String question, String correctAnswer, String[] answerOptions) {
this.question = question;
this.correctAnswer = correctAnswer;
this.answerOptions = answerOptions;
}
public String getQuestion() {
return question;
}
public String[] getAnswerOptions() {
return answerOptions;
}
public String getCorrectAnswer() {
return correctAnswer;
}
public static void main(String[] args) {
String[] options = new String[]{"yes", "no", "idk i'm color blind"};
//Here's how we build our Question
Question myQuestion = new Question("Is the sky blue", "yes", options);
// We're going to print out the stuff
System.out.println("Our Question is: " + myQuestion.getQuestion());
/*
* Here we use the Arrays.toString to print our array, otherwise it prints like String@234231. You can find more on this by doing a google search.
*/
System.out.println("Our Options are: " + Arrays.toString(myQuestion.getAnswerOptions()));
System.out.println("Our answer is: " + myQuestion.getCorrectAnswer());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment