Skip to content
Snippets Groups Projects
Commit 2d8d8e76 authored by Simon Barrett's avatar Simon Barrett
Browse files

Working Software

parent 42391993
No related branches found
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
......@@ -43,14 +43,23 @@ public class QuizSystem {
however at this stage I don't think it's necessary. It is enough that they make it more readable.
*/
Lesson chosenLesson = chooseLessonToComplete(cmt652);
continueWithQuiz = checkUserDecision(users);
String userName = checkIfUserWantsToDoQuiz(chosenLesson);
if(continueWithQuiz) {
Lesson chosenLesson = chooseLessonToComplete(cmt652);
addUserProgressToCompletionData(users, userName, chosenLesson);
String userName = checkIfUserWantsToDoQuiz(chosenLesson);
addUserProgressToCompletionData(users, userName, chosenLesson);
}
continueWithQuiz = checkUserDecision(users);
}
System.out.println(" ");
System.out.println(" + ----------------------------------------------------------- +");
System.out.println(" + | Thank you for playing the MSc Software Engineering Quiz | +");
System.out.println(" + | Have a great day!!! | +");
System.out.println(" + ----------------------------------------------------------- +");
}
/**
......@@ -92,7 +101,6 @@ public class QuizSystem {
userName = ScannerExtension.scanStringToLowercase();
System.out.println("Record of Lesson Completion saved under username: " + userName);
System.out.println(" ");
System.out.println(" ** Going back to the main menu **");
}
System.out.println(" ");
return userName;
......@@ -118,22 +126,37 @@ public class QuizSystem {
/**
* Checks if user wants to continue quiz, see their completion data or see everyone's completion data.
*
* @param users
* @return This will tell the while loop if the quiz should run again
*/
public static boolean checkUserDecision(UserCompletionData users) {
boolean continueWithQuiz = true;
System.out.println("What would you like to do next:");
System.out.println("See the list of lessons? Type (l)");
System.out.println("Check your progress? Type (data)");
System.out.println("Exit Game? Type (n)");
String userDecision = ScannerExtension.gameDecision();
if (userDecision.equals("data")) {
System.out.println("Please type in your name to access your data, or all to print all user data");
// Create Main Menu text
System.out.println(" ");
System.out.println(" + ------------------------------------------------ +");
System.out.println(" + | MAIN MENU | +");
System.out.println(" + ------------------------------------------------ +");
System.out.println(" What would you like to do?");
System.out.println(" ");
// Create a list from user to choose from
System.out.println("Please pick from one of the options:");
System.out.println("[1] See the list of lessons");
System.out.println("[2] Check your progress");
System.out.println("[3] Exit Game");
System.out.println("By pressing the corresponding number (1, 2, 3) :");
// User makes choice
int userDecision = ScannerExtension.scanForUserIntChoice(3);
// User choice evaluated (these values have been hard-coded as it is unlikely the menu will change and if it does
// then it will likely be refactored at that time)
if (userDecision == 2) {
System.out.println("Please type in your name to access your data, or (all) to print all user data");
ScannerExtension.viewUserData(users);
} else if (userDecision.equals("n")) {
} else if (userDecision == 3) {
continueWithQuiz = false;
System.out.println("Thank you for playing the MSc software engineering quiz game");
}
return continueWithQuiz;
}
......
......@@ -80,30 +80,6 @@ public class ScannerExtension {
return nextString;
}
/**
* User can choose between l,data or n, this will be converted to lowerCase so capitalized versions work aswell
* <p>
* Method will keep asking for a user choice until they pick a correctEntry
* @return l, data or n
*/
public static String gameDecision() {
boolean correctEntry = false;
String nextString = scanner.next();
nextString = nextString.toLowerCase();
while (!correctEntry) {
if(nextString.equals("l") || nextString.equals("data") || nextString.equals("n")) {
correctEntry = true;
} else {
System.out.println("Incorrect entry!");
System.out.println("Please choose l or data or n");
nextString = scanner.next();
nextString = nextString.toLowerCase();
}
}
return nextString;
}
/**
* User can type in all to see all users data or theirs own name to check their data
* <p>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment