From 56eaf9a9b38c3db6848bf5b64604323d540a251a Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Sun, 20 Feb 2022 21:15:50 +0100 Subject: [PATCH] added TODOs for many things that need to be done in the backend --- .../general/hackyquizbot/QuizBackend.java | 76 ++++++++++++++++--- 1 file changed, 66 insertions(+), 10 deletions(-) diff --git a/src/main/java/linux/general/hackyquizbot/QuizBackend.java b/src/main/java/linux/general/hackyquizbot/QuizBackend.java index 87547b9..aef9e7f 100644 --- a/src/main/java/linux/general/hackyquizbot/QuizBackend.java +++ b/src/main/java/linux/general/hackyquizbot/QuizBackend.java @@ -1,48 +1,98 @@ package linux.general.hackyquizbot; +import java.util.ArrayList; + public class QuizBackend { + private static Question[] allQuestions; + private static String[] categories; + + static { + //TODO: populate allQuestions + //TODO: populate categories + } + public static String[] getCategories() { - return null; + return categories; } public static Question getRandomQuestionForCategory(String category) { + //TODO: loop + //TODO: pick random question + //TODO: check if question is in category, return if it is + return null; + } + + public static Question getNewRandomQuestionForCategory(String discordUserID, String category) { + //TODO: get list of previously displayed questions for that user + //TODO: retrieve list of answers that user has given to get the question IDs from there + //TODO: find a random question that isn’t on said list + //TODO: add the question to said list and return it return null; } public static int getScoreForUser(String discordUserID) { - return 0; + int score = 0; + //TODO: iterate over all questions + //TODO: get achieved score for the user for the question + //TODO: add to score + return score; } public static class Question { + private String text; + private char[] validAnswers; + private char[] correctAnswers; + private int scoreValue; + private int ID; + private ArrayList categories = new ArrayList(); + /** - * + * @param ID unique ID for the question * @param question The string for the question text - * @param answers The multiple choice answers + * @param answers The multiple choice answers * @param mask A mask to be laid over answers to decide which answers are correct and which aren’t * @param scoreValue See getQuestionScoreValue() */ - public Question(String question, String[] answers, boolean[] mask, int scoreValue) { - + public Question(int ID, String question, String[] answers, boolean[] mask, int scoreValue) { + //TODO: build text, valid answers and correct answers + this.ID = ID; + this.scoreValue = scoreValue; + } + + //TODO: need a way to get back from the answer letter to the text answer and vice versa + + public boolean isInCategory(String category) { + for (int i=0; i