Fakultas Ilmu Komputer UI

Commit de372331 authored by saddamonpc's avatar saddamonpc
Browse files

Move appointmentList in Student and TeachingAssistant to its superclass UserStudent

parent d1ad93da
......@@ -20,7 +20,7 @@ public class Main {
UserList userList;
// --------Uncomment this for the "hardcoded" version.
reset();
// reset();
while (true) {
......
......@@ -8,7 +8,6 @@ import softeng.g4.calendar.SeeCalendarWithoutPermission;
import java.util.ArrayList;
public class Student extends UserStudent {
private ArrayList<Appointment> appointmentList = new ArrayList<Appointment>();
// Constructor
public Student(String username, String fullname, long npm, UserList userList) {
......@@ -25,17 +24,12 @@ public class Student extends UserStudent {
// Adds appointment with the corresponding TeachingAssistant
public void setAppointment(String date, String TAusername, String startTime, String endTime, String description, UserList userList) {
TeachingAssistant ta = userList.searchTA(TAusername);
if(ta.getUsername().equals("falseTA")){
if (ta.getUsername().equals("falseTA")) {
System.out.println("TA not found");
} else {
Appointment newAppointment = new Appointment(date, this, ta, startTime, endTime, description);
this.appointmentList.add(newAppointment);
this.getAppointmentList().add(newAppointment);
ta.getAppointmentList().add(newAppointment);
}
}
public ArrayList<Appointment> getAppointmentList() {
return this.appointmentList;
}
}
......@@ -11,7 +11,6 @@ import java.util.ArrayList;
public class TeachingAssistant extends UserStudent {
private Admin askPermissionAdmin = null;
private Calendar calendar = new Calendar();
private ArrayList<Appointment> appointmentList = new ArrayList<Appointment>();
// Constructor
public TeachingAssistant(String username, String fullname, long npm, UserList userList) {
......@@ -39,14 +38,14 @@ public class TeachingAssistant extends UserStudent {
// Accept appointment
public void acceptAppointment(String id, UserList userList) {
boolean found = false;
for (Appointment appointment : appointmentList) {
for (Appointment appointment : this.getAppointmentList()) {
if (appointment.getId().equals(id)) {
found = true;
appointment.setStatus("Accepted");
Student student = userList.searchStudent(appointment.getStudent().getUsername());
for (Appointment studentappointment : student.getAppointmentList()) {
if (studentappointment.getId().equals(id)) {
studentappointment.setStatus("Accepted");
for (Appointment studentAppointment : student.getAppointmentList()) {
if (studentAppointment.getId().equals(id)) {
studentAppointment.setStatus("Accepted");
}
}
}
......@@ -61,14 +60,14 @@ public class TeachingAssistant extends UserStudent {
// Reject appointment
public void rejectAppointment(String id, UserList userList) {
boolean found = false;
for (Appointment appointment : appointmentList) {
for (Appointment appointment : this.getAppointmentList()) {
if (appointment.getId().equals(id)) {
found = true;
appointment.setStatus("Rejected");
Student student = userList.searchStudent(appointment.getStudent().getUsername());
for (Appointment studentappointment : student.getAppointmentList()) {
if (studentappointment.getId().equals(id)) {
studentappointment.setStatus("Rejected");
for (Appointment studentAppointment : student.getAppointmentList()) {
if (studentAppointment.getId().equals(id)) {
studentAppointment.setStatus("Rejected");
}
}
}
......@@ -103,8 +102,4 @@ public class TeachingAssistant extends UserStudent {
public Calendar getCalendar() {
return calendar;
}
public ArrayList<Appointment> getAppointmentList() {
return this.appointmentList;
}
}
package softeng.g4.user;
import softeng.g4.appointment.Appointment;
import java.util.ArrayList;
public abstract class UserStudent extends User {
private long npm;
private ArrayList<Appointment> appointmentList = new ArrayList<Appointment>();
public long getNPM() {
return npm;
......@@ -10,4 +15,8 @@ public abstract class UserStudent extends User {
public void setNPM(long npm) {
this.npm = npm;
}
public ArrayList<Appointment> getAppointmentList() {
return this.appointmentList;
}
}
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