Fakultas Ilmu Komputer UI

Commit 58edd09e authored by Bagus Prabowo's avatar Bagus Prabowo
Browse files

Merge bagus2, wishnu, and altaaj

parent 6d0cb8f4
Pipeline #81831 passed with stages
in 5 minutes and 20 seconds
......@@ -37,6 +37,9 @@ public class Student extends Role {
System.out.println("11. Delete a timetable");
System.out.println("12. Add an assignment");
System.out.println("13. See the list of assignments");
System.out.println("14. Validate assignments");
System.out.println("15. Update an assignments");
System.out.println("16. Delete an assignments");
}
@Override
......@@ -283,11 +286,67 @@ public class Student extends Role {
break;
}
case 14:
System.out.println("Pick the assignment that you want to validate:");
String[] assignmentsPicked = in.next().split("");
System.out.println("Picked: ");
for (String s: assignmentsPicked) {
System.out.println(s + " " + assignmentList.getAssignmentList().get(Integer.parseInt(s) - 1).getAssignmentName());
String courseAssignment = assignmentList.getAssignmentList().get(Integer.parseInt(s) - 1).getAssignmentCourse().getCourseName();
String assignmentName = assignmentList.getAssignmentList().get(Integer.parseInt(s) - 1).getAssignmentName();
validateAssignment(courseAssignment, assignmentName);
}
break;
case 15:
System.out.println("Update an assignment: ");
System.out.println("===============================");
System.out.println("Pick an assignment to update: ");
assignmentList.listToString(assignmentList.getAssignmentList());
assignmentsPicked = in.next().split("");
System.out.println("Picked: ");
for (String s: assignmentsPicked) {
System.out.println(s + " " + assignmentList.getAssignmentList().get(Integer.parseInt(s) - 1).getAssignmentName());
assignment = assignmentList.getAssignmentList().get(Integer.parseInt(s) - 1);
System.out.println("Enter new due date: yyyy-MM-dd");
String updateDate = in.nextLine();
dueDate = LocalDate.parse(updateDate);
assignment.setDueDate(dueDate);
String courseAssignment = assignmentList.getAssignmentList().get(Integer.parseInt(s) - 1).getAssignmentCourse().getCourseName();
String assignmentName = assignmentList.getAssignmentList().get(Integer.parseInt(s) - 1).getAssignmentName();
validateAssignment(courseAssignment, assignmentName);
}
break;
case 16:
System.out.println("Pick an assignment to delete: ");
assignmentsPicked = in.next().split("");
System.out.println("Picked: ");
for (String s: assignmentsPicked) {
System.out.println(s + " " + assignmentList.getAssignmentList().get(Integer.parseInt(s) - 1).getAssignmentName());
assignmentList.getAssignmentList().get(Integer.parseInt(s) - 1).getAssignmentCourse().
deleteAssignment(assignmentList.getAssignmentList().get(Integer.parseInt(s) - 1));
assignmentList.deleteAssignment(assignmentList.getAssignmentList().get(Integer.parseInt(s) - 1));
System.out.println("Assignment deleted.");
break;
}
default:
}
}
private void validateAssignment(String courseName, String assignmentName) {
Assignment toValidate = courseList.getCourse(courseName).getAssignment(assignmentName);
toValidate.addValidatedBy(Main.currentUser);
}
public HashMap<String, Course> listToHashmap(List<Course> list){
HashMap<String, Course> hashMap = new HashMap<>();
......
......@@ -8,6 +8,7 @@ import Softeng.Group3.SiJadwal.repository.AssignmentList;
import Softeng.Group3.SiJadwal.repository.CourseList;
import Softeng.Group3.SiJadwal.repository.TimetableList;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
......@@ -27,7 +28,7 @@ public class TeachingAssistant extends Role {
private String assignmentName;
private Course assignmentCourse;
private LocalDateTime dueDate;
private LocalDate dueDate;
private Boolean validated;
private Set<User> validatedBy = new HashSet<>();
private User createdBy;
......@@ -85,10 +86,9 @@ public class TeachingAssistant extends Role {
courseList.getCourseList().get(Integer.parseInt(s) - 1));
}
System.out.println("Enter due date: yyyy-MM-dd HH:mm");
System.out.println("Enter due date: yyyy-MM-dd");
String date = in.nextLine();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
dueDate = LocalDateTime.parse(date, formatter);
dueDate = LocalDate.parse(date);
assignment.setDueDate(dueDate);
assignment.setCreatedBy(Main.currentUser);
......@@ -138,10 +138,9 @@ public class TeachingAssistant extends Role {
assignment = assignmentList.getAssignmentList().get(Integer.parseInt(s) - 1);
System.out.println("Enter new due date: yyyy-MM-dd HH:mm");
System.out.println("Enter new due date: yyyy-MM-dd");
String updateDate = in.nextLine();
DateTimeFormatter updateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
dueDate = LocalDateTime.parse(updateDate, updateFormatter);
dueDate = LocalDate.parse(updateDate);
assignment.setDueDate(dueDate);
......
package Softeng.Group3.SiJadwal.model;
import Softeng.Group3.SiJadwal.actor.Role;
import Softeng.Group3.SiJadwal.actor.RoleType;
import Softeng.Group3.SiJadwal.actor.User;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.HashSet;
import java.util.Set;
......@@ -13,7 +11,7 @@ public class Assignment {
private String assignmentName;
private Course assignmentCourse;
private LocalDateTime dueDate;
private LocalDate dueDate;
private Boolean validated;
private Set<User> validatedBy = new HashSet<>();
private User createdBy;
......@@ -25,7 +23,7 @@ public class Assignment {
public Assignment() {
}
public Assignment(String assignmentName, Course assignmentCourse, LocalDateTime dueDate, Boolean validated, Set<User> validatedBy,User createdBy) {
public Assignment(String assignmentName, Course assignmentCourse, LocalDate dueDate, Boolean validated, Set<User> validatedBy,User createdBy) {
this.assignmentName = assignmentName;
this.assignmentCourse = assignmentCourse;
this.dueDate = dueDate;
......@@ -46,9 +44,9 @@ public class Assignment {
this.assignmentCourse = assignmentCourse;
}
public LocalDateTime getDueDate() { return dueDate; }
public LocalDate getDueDate() { return dueDate; }
public void setDueDate(LocalDateTime dueDate) { this.dueDate = dueDate; }
public void setDueDate(LocalDate dueDate) { this.dueDate = dueDate; }
public Boolean getValidated() {
return validationChecker();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment