Fakultas Ilmu Komputer UI

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

Delete Timetable (not final)

parent 408401d2
admin,Admin
st,Student
ta,Teaching Assistant
\ No newline at end of file
ta,Teaching Assistant
......@@ -27,6 +27,7 @@ public class Student extends Role {
System.out.println("7. See the list of timetable");
System.out.println("8. Add Course to a timetable");
System.out.println("9. Find a timetable");
System.out.println("10. Delete a timetable");
}
@Override
......@@ -39,28 +40,29 @@ public class Student extends Role {
System.out.println("Create a new timetable");
System.out.println("===============================");
TimetableList TimeList = new TimetableList();
Timetable newTimetable;
System.out.println("Timetable Name?");
timetableName = in.next();
newTimetable = timetableList.getTimetable(timetableName, Main.currentUser);
if (newTimetable != null) {
System.out.println("Timetable exists.. Updating..");
} else {
System.out.println("Creating new Timetable...");
newTimetable = new Timetable();
newTimetable.setTimetableName(timetableName);
newTimetable.setOwner(Main.currentUser);
System.out.println(Main.currentUser.getUsername());
if(timetableList.getTimetable(timetableName, Main.currentUser) != null){
System.out.println("The user does not exist");
return;
}
System.out.println("Creating new Timetable...");
newTimetable = new Timetable();
newTimetable.setTimetableName(timetableName);
newTimetable.setOwner(Main.currentUser);
System.out.println(Main.currentUser.getUsername());
// Set Timetable owner
System.out.println("Pick some courses to add (Comma separated): ");
courseList.listToString(courseList.getCourseList());
// Reset maybe?
String[] coursesPicked = null;
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());
......@@ -73,7 +75,7 @@ public class Student extends Role {
System.out.println(newTimetable.getTimetableName());
int i = 1;
for (Course c: newTimetable.getCourses()) {
System.out.println(i++ + " " + c.getCourseName());
System.out.println(i++ + ". " + c.getCourseName());
}
timetableList.addTimetable(newTimetable);
......@@ -133,6 +135,22 @@ public class Student extends Role {
break;
}
case 10:
TimetableList delTable = new TimetableList();
System.out.println("Please enter the timetable name that you want to delete: ");
String tableDel = in.next();
if(delTable.getTimetable(tableDel, Main.currentUser) == null){
System.out.println("The timetable does not exist");
return;
}
delTable.deleteTimetable("tableDel");
System.out.println("Timetable deleted.");
break;
default:
}
}
......
......@@ -2,10 +2,6 @@ package Softeng.Group3.SiJadwal.repository;
import java.io.*;
import java.sql.Time;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import Softeng.Group3.SiJadwal.actor.RoleType;
public class CSVOperator {
......
package Softeng.Group3.SiJadwal.repository;
import Softeng.Group3.SiJadwal.Main;
import Softeng.Group3.SiJadwal.actor.RoleType;
import Softeng.Group3.SiJadwal.actor.User;
import Softeng.Group3.SiJadwal.model.Course;
......@@ -50,4 +51,9 @@ public class TimetableList {
}
}
public void deleteTimetable(String table){
Timetable delTable = getTimetable(table, Main.currentUser);
allTimetableList.remove(delTable);
}
}
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