Created
March 20, 2016 20:44
-
-
Save AnEmortalKid/d7484cbc1129f9f06c2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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