Fakultas Ilmu Komputer UI

Commit 4d939b3c authored by Al Taaj Kautsar Supangkat's avatar Al Taaj Kautsar Supangkat
Browse files

Create assignment update and assignment delete feature

parent 5883da82
Pipeline #81781 passed with stages
in 3 minutes and 32 seconds
......@@ -36,3 +36,11 @@ st,name,rpl
st,name,rpl
st,name,rpl,adpro
st,name,rpl
st,tb,rpl,adpro
st,tb,rpl,adpro
st,tb,rpl,adpro
st,name,rpl
st,tb,rpl,adpro
st,tb,rpl
st,tb,rpl,adpro
st,tb,rpl,adpro
Softeng/Group3/SiJadwal/repository/TimetableList.java
Softeng.Group3.SiJadwal.repository.TimetableList
Softeng/Group3/SiJadwal/repository/UserList.java
Softeng.Group3.SiJadwal.repository.UserList
Softeng/Group3/SiJadwal/utility/InputReader.java
Softeng.Group3.SiJadwal.utility.InputReader
Softeng/Group3/SiJadwal/repository/CSVUser.java
Softeng.Group3.SiJadwal.repository.CSVUser
Softeng/Group3/SiJadwal/Main.java
Softeng.Group3.SiJadwal.Main
Softeng/Group3/SiJadwal/actor/RoleType.java
Softeng.Group3.SiJadwal.actor.RoleType
Softeng.Group3.SiJadwal.actor.RoleType$1
Softeng/Group3/SiJadwal/repository/CSVCourse.java
Softeng.Group3.SiJadwal.repository.CSVCourse
Softeng/Group3/SiJadwal/repository/TimetableList.java
Softeng.Group3.SiJadwal.repository.TimetableList
Softeng/Group3/SiJadwal/repository/CSVOperator.java
Softeng.Group3.SiJadwal.repository.CSVOperator
Softeng/Group3/SiJadwal/model/Course.java
Softeng.Group3.SiJadwal.model.Course
Softeng/Group3/SiJadwal/repository/CourseList.java
Softeng.Group3.SiJadwal.repository.CourseList
Softeng/Group3/SiJadwal/repository/CSVCourse.java
Softeng.Group3.SiJadwal.repository.CSVCourse
Softeng/Group3/SiJadwal/actor/Role.java
Softeng.Group3.SiJadwal.actor.Role
Softeng/Group3/SiJadwal/Main.java
Softeng.Group3.SiJadwal.Main
Softeng/Group3/SiJadwal/repository/CSVOperator.java
Softeng.Group3.SiJadwal.repository.CSVOperator
Softeng/Group3/SiJadwal/model/Timetable.java
Softeng.Group3.SiJadwal.model.Timetable
Softeng/Group3/SiJadwal/repository/CSVTimetable.java
Softeng.Group3.SiJadwal.repository.CSVTimetable
Softeng/Group3/SiJadwal/actor/Admin.java
......@@ -24,13 +31,6 @@ Softeng/Group3/SiJadwal/repository/AssignmentList.java
Softeng.Group3.SiJadwal.repository.AssignmentList
Softeng/Group3/SiJadwal/model/Assignment.java
Softeng.Group3.SiJadwal.model.Assignment
Softeng/Group3/SiJadwal/model/Timetable.java
Softeng.Group3.SiJadwal.model.Timetable
Softeng/Group3/SiJadwal/repository/UserList.java
Softeng.Group3.SiJadwal.repository.UserList
Softeng/Group3/SiJadwal/actor/RoleType.java
Softeng.Group3.SiJadwal.actor.RoleType
Softeng.Group3.SiJadwal.actor.RoleType$1
Softeng/Group3/SiJadwal/actor/Student.java
Softeng.Group3.SiJadwal.actor.Student
Softeng/Group3/SiJadwal/actor/TeachingAssistant.java
......
......@@ -83,6 +83,8 @@ public class Student extends Role {
System.out.println("11. Add an assignment");
System.out.println("12. See the list of assignment");
System.out.println("13. Validate Assignment");
System.out.println("14. Update assignment");
System.out.println("15. Delete Assignment");
}
@Override
......@@ -236,7 +238,48 @@ public class Student extends Role {
String assignmentName = assignmentList.getAssignmentList().get(Integer.parseInt(s) - 1).getAssignmentName();
validateAssignment(courseAssignment, assignmentName);
}
break;
case 14:
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 HH:mm");
String updateDate = in.nextLine();
DateTimeFormatter updateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
dueDate = LocalDateTime.parse(updateDate, updateFormatter);
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 15:
System.out.println("Pick an assignment to delete: ");
retrieveAllAssignment();
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:
}
}
......
......@@ -3,6 +3,7 @@ package Softeng.Group3.SiJadwal.actor;
import Softeng.Group3.SiJadwal.Main;
import Softeng.Group3.SiJadwal.model.Assignment;
import Softeng.Group3.SiJadwal.model.Course;
import Softeng.Group3.SiJadwal.model.Timetable;
import Softeng.Group3.SiJadwal.repository.AssignmentList;
import Softeng.Group3.SiJadwal.repository.CourseList;
import Softeng.Group3.SiJadwal.repository.TimetableList;
......@@ -54,6 +55,8 @@ public class TeachingAssistant extends Role {
System.out.println("6. Add an assignment");
System.out.println("7. See the list of assignment");
System.out.println("8. Validate assignment");
System.out.println("9. Update assignment");
System.out.println("10. Delete Assignment");
}
@Override
......@@ -74,7 +77,7 @@ public class TeachingAssistant extends Role {
System.out.println("Pick a course to add assignment: ");
courseList.listToString(courseList.getCourseList());
String[] coursesPicked = in.next().split(",");
String[] coursesPicked = in.next().split("");
System.out.println("Picked: ");
for (String s: coursesPicked) {
System.out.println(s + " " + courseList.getCourseList().get(Integer.parseInt(s) - 1).getCourseName());
......@@ -119,7 +122,54 @@ public class TeachingAssistant extends Role {
String assignmentName = assignmentList.getAssignmentList().get(Integer.parseInt(s) - 1).getAssignmentName();
validateAssignment(courseAssignment, assignmentName);
}
default:
break;
case 9:
System.out.println("Update an assignment: ");
System.out.println("===============================");
System.out.println("Pick an assignment to update: ");
retrieveAllAssignment();
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 HH:mm");
String updateDate = in.nextLine();
DateTimeFormatter updateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
dueDate = LocalDateTime.parse(updateDate, updateFormatter);
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 10:
System.out.println("Pick an assignment to delete: ");
retrieveAllAssignment();
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:
}
}
......
......@@ -71,6 +71,8 @@ public class Course {
assignments.add(assignment);
}
public void deleteAssignment(Assignment assignment){ assignments.remove(assignment); }
public Assignment getAssignment(String assignmentName) {
for (Assignment a: assignments) {
if (a.getAssignmentName().equalsIgnoreCase(assignmentName)) {
......
......@@ -3,6 +3,7 @@ package Softeng.Group3.SiJadwal.repository;
import Softeng.Group3.SiJadwal.actor.User;
import Softeng.Group3.SiJadwal.model.Assignment;
import Softeng.Group3.SiJadwal.model.Course;
import Softeng.Group3.SiJadwal.model.Timetable;
import java.sql.Time;
import java.util.ArrayList;
......@@ -28,6 +29,10 @@ public class AssignmentList {
assignmentList.add(assignment);
}
public void deleteAssignment(Assignment assignment){
assignmentList.remove(assignment);
}
public void listToString(List<Assignment> assignmentList){
int i = 1;
......
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