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

Refactored User and UserCompletionData

parent 0c238c83
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
No preview for this file type
......@@ -10,6 +10,8 @@ public class User {
this.userRecord = new ArrayList<>();
}
// GETTER METHODS
public String getUsername() {
return username;
}
......@@ -17,21 +19,28 @@ public class User {
public ArrayList<Lesson> getUserRecord() {
return userRecord;
}
// END GETTER METHODS
// CUSTOM METHODS
public void addToUserRecord(Lesson currentIteration) {
/**
* Checks if the user already has a record and updates quiz score if necessary or adds the current
* lesson data to the user record
* @param currentLesson
*/
public void addToUserRecord(Lesson currentLesson) {
boolean inUserRecord = false;
int userPlace = 0;
for(int i = 0; i < userRecord.size(); i++) {
if(userRecord.get(i).getLessonTitle().equals(currentIteration.getLessonTitle())){
if(userRecord.get(i).getLessonTitle().equals(currentLesson.getLessonTitle())){
inUserRecord = true;
userPlace = i;
}
}
if(inUserRecord) {
userRecord.get(userPlace).setQuizScore(currentIteration.getQuizScore());
userRecord.get(userPlace).setQuizScore(currentLesson.getQuizScore());
} else {
userRecord.add(currentIteration);
userRecord.add(currentLesson);
}
}
}
......@@ -8,10 +8,17 @@ public class UserCompletionData {
this.users = new ArrayList<>();
}
// GETTER METHODS
public ArrayList<User> getUsers() {
return users;
}
// END GETTER METHODS
/**
* Adds a user to the ArrayList
* @param user
*/
public void add(User user) {
users.add(user);
}
......@@ -31,6 +38,9 @@ public class UserCompletionData {
return -1;
}
/**
* Prints out every users completion data
*/
public void printAllUsersData() {
for(int i = 0; i < users.size(); i++) {
User currentUser = users.get(i);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment