Fakultas Ilmu Komputer UI

Commit a6238ecc authored by Bagus Prabowo's avatar Bagus Prabowo
Browse files

Final Application Push

parent e25589ee
Pipeline #81871 passed with stages
in 4 minutes and 55 seconds
it1,st,rpl,2020-01-01,false
......@@ -3,10 +3,8 @@ package Softeng.Group3.SiJadwal;
import Softeng.Group3.SiJadwal.actor.Role;
import Softeng.Group3.SiJadwal.actor.RoleType;
import Softeng.Group3.SiJadwal.actor.User;
import Softeng.Group3.SiJadwal.repository.CSVOperator;
import Softeng.Group3.SiJadwal.repository.CourseList;
import Softeng.Group3.SiJadwal.repository.TimetableList;
import Softeng.Group3.SiJadwal.repository.UserList;
import Softeng.Group3.SiJadwal.model.Assignment;
import Softeng.Group3.SiJadwal.repository.*;
import Softeng.Group3.SiJadwal.utility.InputReader;
import java.io.*;
......@@ -22,7 +20,7 @@ public class Main {
public static UserList userList = new UserList();
private static CourseList courseList = new CourseList();
private static TimetableList timetableList = new TimetableList();
private static AssignmentList assignmentList = new AssignmentList();
public static Boolean isRunning = true;
public static Boolean isLoggedIn = false;
......@@ -96,7 +94,7 @@ public class Main {
public static void main(String[] args) {
CSVOperator.InitUsersCourses(userList, courseList, timetableList);
CSVOperator.InitUsersCourses(userList, courseList, timetableList, assignmentList);
while (isRunning) {
System.out.println("ON-BOARDING");
......
......@@ -313,41 +313,48 @@ public class Student extends Role {
System.out.println("===============================");
System.out.println("Pick an assignment to update: ");
assignmentList.listToString(assignmentList.getAssignmentList());
String[] assignmentsPicked = in.next().split("");
int cnt2 = 1;
for(Assignment s : assignmentList.getAssignmentList()){
System.out.println(cnt2 + ". " + s.getAssignmentName());
cnt2++;
}
String updateAssg = in.next();
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);
Assignment picked2 = assignmentList.getAssignmentList().get(Integer.parseInt(updateAssg) - 1);
System.out.println("Picked: " + picked2.getAssignmentName());
String courseAssignment2 = assignmentList.getAssignmentList().get(Integer.parseInt(s) - 1).getAssignmentCourse().getCourseName();
String assignmentName2 = assignmentList.getAssignmentList().get(Integer.parseInt(s) - 1).getAssignmentName();
validateAssignment(courseAssignment2, assignmentName2);
System.out.println("Enter new due date: yyyy-MM-dd");
String updateDate = in.nextLine();
dueDate = LocalDate.parse(updateDate);
picked2.setDueDate(dueDate);
CSVAssignment.updateAssignment(picked2);
}
break;
case 16:
System.out.println("Pick an assignment to delete: ");
assignmentsPicked = in.next().split("");
int cnt3 = 1;
for(Assignment s : assignmentList.getAssignmentList()){
System.out.println(cnt3 + ". " + s.getAssignmentName());
cnt3++;
}
String delAssg = in.next();
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));
Assignment picked3 = assignmentList.getAssignmentList().get(Integer.parseInt(delAssg) - 1);
System.out.println("Assignment deleted.");
break;
}
System.out.println("Picked: " + picked3.getAssignmentName());
assignmentList.deleteAssignment(picked3);
CSVAssignment.deleteAssignment(picked3.getAssignmentName());
default:
}
......
......@@ -137,46 +137,48 @@ public class TeachingAssistant extends Role {
System.out.println("===============================");
System.out.println("Pick an assignment to update: ");
retrieveAllAssignment();
assignmentsPicked = in.next().split("");
int cnt2 = 1;
for(Assignment s : assignmentList.getAssignmentList()){
System.out.println(cnt2 + ". " + s.getAssignmentName());
cnt2++;
}
String updateAssg = in.next();
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);
Assignment picked2 = assignmentList.getAssignmentList().get(Integer.parseInt(updateAssg) - 1);
System.out.println("Enter new due date: yyyy-MM-dd");
String updateDate = in.nextLine();
dueDate = LocalDate.parse(updateDate);
assignment.setDueDate(dueDate);
System.out.println("Picked: " + picked2.getAssignmentName());
System.out.println("Enter new due date: yyyy-MM-dd");
String updateDate = in.nextLine();
dueDate = LocalDate.parse(updateDate);
picked2.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);
CSVAssignment.updateAssignment(picked2);
}
break;
case 10:
System.out.println("Pick an assignment to delete: ");
retrieveAllAssignment();
assignmentsPicked = in.next().split("");
int cnt3 = 1;
for(Assignment s : assignmentList.getAssignmentList()){
System.out.println(cnt3 + ". " + s.getAssignmentName());
cnt3++;
}
String delAssg = in.next();
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));
Assignment picked3 = assignmentList.getAssignmentList().get(Integer.parseInt(delAssg) - 1);
System.out.println("Assignment deleted.");
break;
}
default:
System.out.println("Picked: " + picked3.getAssignmentName());
assignmentList.deleteAssignment(picked3);
CSVAssignment.deleteAssignment(picked3.getAssignmentName());
}
}
......
......@@ -76,6 +76,35 @@ public class CSVAssignment {
}
}
public static void updateAssignment(Assignment assg){
try{
BufferedReader check = new BufferedReader(new FileReader("Assignments.csv"));
String row;
List<String> newList = new ArrayList<>();
while((row = check.readLine()) != null){
String[] assgWritten = row.split(",");
if((assgWritten[0].equalsIgnoreCase(assg.getAssignmentName()) && assgWritten[2].equalsIgnoreCase(assg.getAssignmentCourse().getCourseName()))){
assgWritten[3] = assg.getDueDate().toString();
}
newList.add(assgWritten[0]);
for(int i = 1; i < assgWritten.length; i++) {
newList.add(",");
newList.add(assgWritten[i]);
}
newList.add("\n");
} check.close();
FileWriter reader = new FileWriter("Assignments.csv");
for (String s : newList) {
reader.append(s);
}reader.flush();
reader.close();
}
catch (IOException e) {
System.out.println("File not found.");
e.printStackTrace();
}
}
public static void deleteAssignment(String name){
try{
BufferedReader check = new BufferedReader(new FileReader("Assignments.csv"));
......
......@@ -2,12 +2,15 @@ package Softeng.Group3.SiJadwal.repository;
import java.io.*;
import java.sql.Time;
import java.time.LocalDate;
import Softeng.Group3.SiJadwal.actor.RoleType;
import Softeng.Group3.SiJadwal.model.Assignment;
import Softeng.Group3.SiJadwal.model.Course;
import Softeng.Group3.SiJadwal.model.Timetable;
public class CSVOperator {
public static void InitUsersCourses(UserList userlist, CourseList courselist, TimetableList timetableList){
public static void InitUsersCourses(UserList userlist, CourseList courselist, TimetableList timetableList, AssignmentList assignmentList){
try{
BufferedReader check = new BufferedReader(new FileReader("Users.csv"));
String row;
......@@ -39,6 +42,25 @@ public class CSVOperator {
timetableList.addTimetable(tables[0], newTable);
}
check.close();
check = new BufferedReader(new FileReader("Assignments.csv"));
while((row = check.readLine()) != null){
String[] assgs;
assgs = row.split(",");
Assignment newAssg = new Assignment();
newAssg.setAssignmentName(assgs[0]);
newAssg.setCreatedBy(userlist.getUser(assgs[1]));
newAssg.setAssignmentCourse(courselist.getCourse(assgs[2]));
String[] date = assgs[3].split("-");
newAssg.setDueDate(LocalDate.of(Integer.parseInt(date[0]), Integer.parseInt(date[1]), Integer.parseInt(date[2])));
newAssg.setValidated(Boolean.valueOf(assgs[4]));
for(int i = 5; i < assgs.length; i++){
newAssg.addValidatedBy(userlist.getUser(assgs[i]));
}
assignmentList.addAssignment(newAssg.getAssignmentName(), newAssg);
}
check.close();
}
catch (IOException e) {
System.out.println("File not found.");
......
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