Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void addQuestion()
- {
- boolean checkCat = false;
- Scanner scan = new Scanner(System.in);
- System.out.println("Enter the author of the question: ");
- String author = scan.nextLine();
- String category;
- while(!checkCat)
- {
- System.out.println("Enter the category of the question: ");
- category = scan.nextLine();
- for (Category c : Category.values()) {
- if (c.name().equals(category)) {
- checkCat = true;
- }
- }
- if(!checkCat)
- {
- System.out.println("The category must be one of these");
- for(Category c : Category.values())
- {
- System.out.println(c);
- }
- }
- }
- System.out.println("Enter the statement of the question: ");
- String statement = scan.nextLine();
- System.out.println("Enter the answer of the question: ");
- String answer = scan.nextLine();
- Question q = new Question(author, category, statement, answer); // <---- "Change category to Category"
- addQuestion(q);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement