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

Start of refactor on Criteria 3

parent 9f51f3e5
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
......@@ -12,7 +12,7 @@ public class QuizSystem {
// Set up the quiz data and storage to keep the users progress
MyData myData = new MyData();
boolean continueWithQuiz = true;
ArrayList<User> users = new ArrayList<>();
UserCompletionData users = new UserCompletionData();
// Start the while loop so quiz repeats itself until user quits
while (continueWithQuiz) {
......@@ -53,14 +53,12 @@ public class QuizSystem {
System.out.println("Record of completion saved under username: " + userName);
}
// Add User progress to ArrayList and print out all user progress
// Add User progress to UserCompletionData and print out all user progress
User recordCurrentIteration = new User(userName, currentIteration);
users.add(recordCurrentIteration);
for(int i = 0; i < users.size(); i++) {
User currentUser = users.get(i);
System.out.println(currentUser.getUsername() + currentUser.getUserRecord().toString());
users.printAllUsersData();
}
// User to decide to finish game or go back to starting menu
System.out.println("Would you like to continue playing or exit the game (y for continue playing, n to exit game)");
String userContinue = ScannerExtension.chooseYorN();
......
import java.util.ArrayList;
public class UserCompletionData {
private ArrayList<User> users;
public UserCompletionData() {
this.users = new ArrayList<>();
}
public void add(User user) {
users.add(user);
}
public void printAllUsersData() {
for(int i = 0; i < users.size(); i++) {
User currentUser = users.get(i);
System.out.println(currentUser.getUsername() + currentUser.getUserRecord().toString());
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment