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

Removed myData Class

parent 5e5731c4
No related branches found
No related tags found
No related merge requests found
No preview for this file type
File deleted
No preview for this file type
public class MyData {
LessonReader lessonReader = new LessonReader();
private Lesson htmlLesson = lessonReader.createLessonFromTextFile("HTMLLesson.txt");
private Lesson scrumLesson = lessonReader.createLessonFromTextFile("ScrumLesson.txt");
private Lesson cssLesson = lessonReader.createLessonFromTextFile("CSSLesson.txt");
private Lesson dataTypesLesson = lessonReader.createLessonFromTextFile("DataTypes.txt");
private Lesson oopLesson = lessonReader.createLessonFromTextFile("OOP.txt");
private Lesson keywordsLesson = lessonReader.createLessonFromTextFile("Keywords.txt");
private Lesson[] cmt652LessonsArray = {htmlLesson, cssLesson, scrumLesson, dataTypesLesson,oopLesson,keywordsLesson};
public Module cmt652 = new Module(cmt652LessonsArray);
}
......@@ -9,10 +9,21 @@ public class QuizSystem {
/* This is Basic Set up:
Import the quiz data, set up the User Completion Data Storage, Boolean to check if user wants to continue
*/
MyData myData = new MyData();
boolean continueWithQuiz = true;
UserCompletionData users = new UserCompletionData();
// Create all the lessons and add them to the module array to use
LessonReader lessonReader = new LessonReader();
Lesson htmlLesson = lessonReader.createLessonFromTextFile("HTMLLesson.txt");
Lesson scrumLesson = lessonReader.createLessonFromTextFile("ScrumLesson.txt");
Lesson cssLesson = lessonReader.createLessonFromTextFile("CSSLesson.txt");
Lesson dataTypesLesson = lessonReader.createLessonFromTextFile("DataTypes.txt");
Lesson oopLesson = lessonReader.createLessonFromTextFile("OOP.txt");
Lesson keywordsLesson = lessonReader.createLessonFromTextFile("Keywords.txt");
Lesson[] cmt652LessonsArray = {htmlLesson, cssLesson, scrumLesson, dataTypesLesson,oopLesson,keywordsLesson};
Module cmt652 = new Module(cmt652LessonsArray);
// Quiz will repeat itself until the user chooses to end it.
// continueWithQuiz can be changed in the method checkUserDecision()
while (continueWithQuiz) {
......@@ -27,26 +38,26 @@ 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(myData);
Lesson chosenLesson = chooseLessonToComplete(cmt652);
String userName = checkIfUserWantsToDoQuiz(chosenLesson);
addUserProgressToCompletionData(users, userName, chosenLesson);
continueWithQuiz = checkUserDecision(users, continueWithQuiz);
continueWithQuiz = checkUserDecision(users);
}
}
/**
* Lists all the lessons in the module, user chooses lesson, user is shown lesson
* @param myData this is all the data needed to run the quiz
* @param module contains the data needed to run the quiz
* @return Returns a Lesson object
*/
public static Lesson chooseLessonToComplete(MyData myData) {
public static Lesson chooseLessonToComplete(Module module) {
// List all the Lessons in the module, Get the User's lesson choice and Print it out
myData.cmt652.listAll();
int choice = ScannerExtension.scanForUserIntChoice(myData.cmt652.getLessonsArrayLength());
Lesson chosenLesson = myData.cmt652.getLesson(choice);
module.listAll();
int choice = ScannerExtension.scanForUserIntChoice(module.getLessonsArrayLength());
Lesson chosenLesson = module.getLesson(choice);
chosenLesson.printLesson();
return chosenLesson;
}
......@@ -102,10 +113,10 @@ public class QuizSystem {
/**
* Checks if user wants to continue quiz, see their completion data or see everyone's completion data.
* @param users
* @param continueWithQuiz
* @return This will tell the while loop if the quiz should run again
*/
public static boolean checkUserDecision(UserCompletionData users, boolean continueWithQuiz) {
public static boolean checkUserDecision(UserCompletionData users) {
boolean continueWithQuiz = true;
System.out.println("Type l to see a list of all lessons, data to see progress or n to exit game :");
String userDecision = ScannerExtension.gameDecision();
if (userDecision.equals("data")) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment