Fakultas Ilmu Komputer UI

Commit 19ade3bd authored by Jerome Emmanuel's avatar Jerome Emmanuel
Browse files

Merge branch 'kevin' into 'master'

Iteration 2

See merge request !1
parents df804047 ceb1c4ef
This diff is collapsed.
package softeng.g4.appointment;
public class Appointment {
import softeng.g4.user.Student;
import softeng.g4.user.TeachingAssistant;
import java.io.Serializable;
import java.util.Random;
public class Appointment implements Serializable {
private String id;
private String date;
private TeachingAssistant ta;
private Student student;
private String startTime;
private String endTime;
private String description;
private String status;
public Appointment(String date, Student student, TeachingAssistant ta, String startTime, String endTime, String decription, String status) {
this.id = generateId();
this.date = date;
this.student = student;
this.ta = ta;
this.startTime = startTime;
this.endTime = endTime;
this.description = decription;
this.status = status;
}
public String getId (){
return id;
}
public void setStatus (String newstatus){
this.status = newstatus;
}
public Student getStudent() {
return student;
}
public String generateId(){
int leftLimit = 65; // letter 'A'
int rightLimit = 90; // letter 'Z'
int targetStringLength = 5;
Random random = new Random();
StringBuilder buffer = new StringBuilder(targetStringLength);
for (int i = 0; i < targetStringLength; i++) {
int randomLimitedInt = leftLimit + (int)
(random.nextFloat() * (rightLimit - leftLimit + 1));
buffer.append((char) randomLimitedInt);
}
String generatedString = buffer.toString();
return generatedString;
}
// public Schedule(String startTime, String endTime) {
// this.name = "Free";
// this.startTime = startTime;
// this.endTime = endTime;
// }
public String toString() {
return "ID: " + id + "\nDate: " + date + "\nStudent: " + student.getUsername() + "\nTA: " + ta.getUsername() + "\nStart Time : " + startTime + "\nEnd Time: " + endTime + "\nDescription: " + description + "\nStatus: " + status;
//return date + student + " " + ta + " " + startTime + " - " + endTime + " " + description + status;
}
}
package softeng.g4.calendar;
import softeng.g4.appointment.Appointment;
import java.io.Serializable;
import java.util.ArrayList;
......@@ -11,6 +13,13 @@ public class Calendar implements Serializable {
private ArrayList<Schedule> friday = new ArrayList<Schedule>();
private ArrayList<Schedule> saturday = new ArrayList<Schedule>();
private ArrayList<Schedule> sunday = new ArrayList<Schedule>();
// private ArrayList<Appointment> A_monday = new ArrayList<>();
// private ArrayList<Appointment> A_tuesday = new ArrayList<>();
// private ArrayList<Appointment> A_wednesday = new ArrayList<>();
// private ArrayList<Appointment> A_thursday = new ArrayList<>();
// private ArrayList<Appointment> A_friday = new ArrayList<>();
// private ArrayList<Appointment> A_saturday = new ArrayList<>();
// private ArrayList<Appointment> A_sunday = new ArrayList<>();
public void showCalendar() {
System.out.println("Monday:");
......@@ -81,4 +90,41 @@ public class Calendar implements Serializable {
break;
}
}
// Add Appointment to calendar
// public void addAppointment(String day, Appointment appointment) {
// switch (day) {
// case "monday":
// A_monday.add(appointment);
// break;
//
// case "tuesday":
// A_tuesday.add(appointment);
// break;
//
// case "wednesday":
// A_wednesday.add(appointment);
// break;
//
// case "thursday":
// A_thursday.add(appointment);
// break;
//
// case "friday":
// A_friday.add(appointment);
// break;
//
// case "saturday":
// A_saturday.add(appointment);
// break;
//
// case "sunday":
// A_sunday.add(appointment);
// break;
//
// // TODO: Need to change default case
// default:
// A_monday.add(appointment);
// break;
// }
// }
}
......@@ -9,8 +9,8 @@ import java.util.ArrayList;
public class Course implements Serializable {
private String name;
private String courseId;
private ArrayList<Student> students;
private ArrayList<TeachingAssistant> teachingAssistants;
private ArrayList<Student> students = new ArrayList<Student>();
private ArrayList<TeachingAssistant> teachingAssistants = new ArrayList<TeachingAssistant>();
private String professor;
private int sks;
private boolean adminPermission;
......@@ -31,6 +31,20 @@ public class Course implements Serializable {
this.teachingAssistants.add(ta);
}
// Prints course details
public void getCourseDetail() {
System.out.println(name + " - " + courseId);
System.out.println("Professor: " + professor);
System.out.println("SKS: " + sks);
System.out.println("Responsible TA(s):");
for (TeachingAssistant ta : teachingAssistants) System.out.println(ta);
}
public String getCourseId() {
return courseId;
}
// toString() method to print the course in an orderly manner
public String toString() {
return name + " - " + courseId + " | Professor: " + professor + " | SKS: " + sks;
}
......
package softeng.g4.course;
import softeng.g4.user.Student;
import softeng.g4.user.User;
import java.io.Serializable;
import java.util.ArrayList;
public class CourseList implements Serializable {
public ArrayList<Course> courseList = new ArrayList<Course>();
// Shows the course list in an orderly manner
public void showCourseList() {
for (int i = 1; i < courseList.size(); i++) {
System.out.println(courseList.get(i));
}
System.out.println();
}
// Returns the corresponding course, if found.
public Course searchCourse(String courseId) {
for (Course course : courseList) {
System.out.println(course);
// Linear search courses by their courseId
if (course.getCourseId().equals(courseId)) {
return course;
}
}
// Returns a course called False Course, so user will have to search the course with the correct course name
return courseList.get(0);
}
}
package softeng.g4.user;
import softeng.g4.appointment.Appointment;
import softeng.g4.course.Course;
import softeng.g4.course.CourseList;
......@@ -17,11 +18,17 @@ public class Admin extends User {
userList.userList.add(this);
}
public void assignRole() {}
// TODO: Change the role of the teaching assistant to something else? (needs to be discussed)
public void assignRole(TeachingAssistant ta) {}
// Assign TA to the course
public void setCourseTA(TeachingAssistant ta, Course course) {
course.setTA(ta);
if (ta.getUsername().equals("falseTA") || course.getCourseId().equals("FALSECOURSE")) {
System.out.println("Wrong TA or CourseId. Try again.");
} else {
System.out.println("Teaching Assistant " + ta.getUsername() + " has successfully assigned to course " + course.getCourseId());
course.setTA(ta);
}
}
// Create course
......@@ -34,15 +41,35 @@ public class Admin extends User {
courseList.showCourseList();
}
public void seeAppointment() {}
// Shows all the users except for the false users
public void getUserList(UserList userList) {
for (User user: userList.userList) {
System.out.println(user);
for (int i = 3; i < userList.userList.size(); i++) {
System.out.println(userList.userList.get(i));
}
System.out.println();
// Uncomment to include the printing of the false users
// for (User user: userList.userList) {
// System.out.println(user);
// }
}
public void seeSchedule() {}
// TODO: Iteration 3 - Admin can see the appointment, if appointment has the permission true
public void seeAppointment(Appointment ap) {}
// TODO: Iteration 3 - Admin can see the TA's calendar, if calendar has the permission true
public void seeCalendar(TeachingAssistant ta) {}
public String toString() {
return username + " - " + fullname;
}
public String getRole() {
return role;
}
public String getUsername() {
return username;
}
}
package softeng.g4.user;
import softeng.g4.calendar.Calendar;
import softeng.g4.calendar.Schedule;
import softeng.g4.appointment.Appointment;
import java.util.ArrayList;
public class Student extends UserStudent {
public void addAppointment() {}
private String username;
private String fullname;
private String role;
private long npm;
public ArrayList<Appointment> appointmentlist = new ArrayList<Appointment>();
// Constructor
public Student(String username, String fullname, long npm, UserList userList) {
this.username = username;
this.fullname = fullname;
this.role = "S";
this.npm = npm;
// Register new TA to the userList
userList.userList.add(this);
}
// TODO: Adds appointment with the corresponding TeachingAssistant
public void setAppointment(String date, String TAusername, String startTime, String endTime, String description, String status, UserList userList) {
TeachingAssistant ta = userList.searchTA(TAusername);
if(ta.getUsername().equals("falseTA")){
System.out.println("TA not found");
} else{
Appointment newAppointment = new Appointment(date, this, ta, startTime, endTime, description, status);
//this.calendar.addAppointment(day, newAppointment);
System.out.println("Appointment's successfully added");
this.appointmentlist.add(newAppointment);
ta.appointmentlist.add(newAppointment);
}
}
public void addAppointment() {
}
// Not a necessary method to implement. Just a bonus if there's enough time.
public void addReminder() {}
// TODO: After adding appointment, the student will have an option to add a description or not.
public void addDescription() {}
public void seeCalendar(long npm) {}
// See this Student's calendar
// temporary calendar
// TODO: Change this method such that it returns the TA's calendar by searching for their username
public void seeCalendar(String TAusername, UserList userList) {
TeachingAssistant ta = userList.searchTA(TAusername);
ta.seeCalendar();
}
public String getRole() {
return role;
}
public String getUsername() {
return username;
}
public String toString() {
return username + " - " + fullname;
}
}
Markdown is supported
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