Fakultas Ilmu Komputer UI

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

Registration flow fix

parents 8bd14ede 9fadb323
......@@ -6,7 +6,6 @@ import Softeng.Group3.SiJadwal.repository.CourseList;
import Softeng.Group3.SiJadwal.repository.UserList;
import java.sql.Time;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -17,30 +16,8 @@ public class Student extends Role {
private CourseList courseList = new CourseList();
// Timetable list
private static List<Timetable> timetableList = new ArrayList<>();
private List<Timetable> getTimetableList() {
return timetableList;
}
private Timetable getTimetable(String timetableName){
for (Timetable timetable: timetableList){
if (timetable.getTimetableName().equalsIgnoreCase(timetableName)){
return timetable;
}
}
return null;
}
private void listToString(List<Timetable> timetableList){
int i = 1;
for (Timetable timetable: timetableList) {
System.out.println(i + ". " + timetable.getTimetableName());
i++;
}
}
// Al Taaj nanti lu pindahin ini list ke class Student yak
@Override
public void exclusiveActions() {
......@@ -53,19 +30,17 @@ public class Student extends Role {
@Override
public void doExclusiveActions(int userAction) {
courseOptions = listToHashmap(courseList.getCourseList());
switch (userAction){
case 6:
// List<Course> courses = new ArrayList<>();
System.out.println("Create a new timetable");
System.out.println("===============================");
System.out.println("Timetable Name?");
timetableName = in.next();
Timetable newTimetable = new Timetable(timetableName);
System.out.println("Pick some courses to add (Comma separated): ");
courseList.listToString(courseList.getCourseList());
String[] coursesPicked = in.next().split(",");
......@@ -81,61 +56,11 @@ public class Student extends Role {
int i = 1;
for (Course c: newTimetable.getCourses()) {
System.out.println(i++ + " " + c.getCourseName());
// courses.add(c);
}
// newTimetable.setCourses(courses);
timetableList.add(newTimetable);
break;
case 7:
listToString(getTimetableList());
break;
case 8:
try {
System.out.println("Add a course to a timetable");
System.out.println("===============================");
System.out.println("Timetable Name?");
timetableName = in.next();
System.out.println("Pick some courses to add (Comma separated): ");
courseList.listToString(courseList.getCourseList());
coursesPicked = in.next().split(",");
System.out.println("Picked: ");
for (String s: coursesPicked) {
System.out.println(s + " " + courseList.getCourseList().get(Integer.parseInt(s) - 1).getCourseName());
getTimetable(timetableName).addCourse(
courseList.getCourseList().get(Integer.parseInt(s) - 1));
}
System.out.println("Timetable created: ");
System.out.println(getTimetable(timetableName).getTimetableName());
int j = 1;
for (Course c: getTimetable(timetableName).getCourses()) {
System.out.println(j++ + " " + c.getCourseName());
}
break;
} catch (NullPointerException e) {
System.out.println("Timetable not found");
break;
}
case 9:
System.out.println("Find timetable by name: ");
try {
String timetableName = in.next();
System.out.println(getTimetable(timetableName).getTimetableName());
System.out.println("Courses: " + getTimetable(timetableName).getCourses().toString());
break;
} catch (NullPointerException e) {
System.out.println("Timetable not found");
break;
}
default:
}
}
......
......@@ -40,8 +40,8 @@ public class Course {
this.endTime = endTime;
}
@Override
public String toString() {
return courseName;
}
// private String startTime;
// private String endTime;
}
package Softeng.Group3.SiJadwal.model;
import Softeng.Group3.SiJadwal.actor.Student;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class Timetable {
private String timetableName;
// private Student owner;
// private Date startDate;
// private Date endDate;
private static List<Course> courses = new ArrayList<>();
public Timetable(String timetableName) {
......@@ -37,30 +31,4 @@ public class Timetable {
public void addCourse(Course course) {
courses.add(course);
}
// public Date getStartDate() {
// return startDate;
// }
//
// public void setStartDate(Date startDate) {
// this.startDate = startDate;
// }
//
// public Date getEndDate() {
// return endDate;
// }
//
// public void setEndDate(Date endDate) {
// this.endDate = endDate;
// }
// public Student getOwner() {
// return owner;
// }
//
// public void setOwner() {
// this.owner = owner;
// }
}
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