Fakultas Ilmu Komputer UI

Commit e123c6eb authored by saddamonpc's avatar saddamonpc
Browse files

User subclasses uses functions and variables from its superclass

parent 71d9c904
Pipeline #82658 passed with stage
in 1 minute and 7 seconds
...@@ -48,17 +48,14 @@ public class Admin extends User { ...@@ -48,17 +48,14 @@ public class Admin extends User {
// } // }
} }
// TODO: Iteration 3 - Admin can see the appointment, if appointment has the permission true // Ask permission to the Teaching Assistant
public void seeAppointment(Appointment ap) {
}
public void askPermission(String username, UserList userList) { public void askPermission(String username, UserList userList) {
TeachingAssistant searchedTA = userList.searchTA(username); TeachingAssistant searchedTA = userList.searchTA(username);
searchedTA.setAskPermissionAdmin(this); searchedTA.setAskPermissionAdmin(this);
System.out.println("You have successfully asked " + searchedTA.getUsername() + " to see their calendar!"); System.out.println("You have successfully asked " + searchedTA.getUsername() + " to see their calendar!");
} }
// TODO: Iteration 3 - Admin can see the TA's calendar, if calendar has the permission true // Admin can see the TA's calendar, if calendar has the permission true
public void seeCalendar(String username, UserList userList) { public void seeCalendar(String username, UserList userList) {
TeachingAssistant searchedTA = userList.searchTA(username); TeachingAssistant searchedTA = userList.searchTA(username);
if (searchedTA.getCalendar().isAdminPermission()) { if (searchedTA.getCalendar().isAdminPermission()) {
......
...@@ -7,19 +7,14 @@ import softeng.g4.appointment.Appointment; ...@@ -7,19 +7,14 @@ import softeng.g4.appointment.Appointment;
import java.util.ArrayList; import java.util.ArrayList;
public class Student extends UserStudent { public class Student extends UserStudent {
private String username;
private String fullname;
private String role;
private long npm;
private ArrayList<Appointment> appointmentList = new ArrayList<Appointment>(); private ArrayList<Appointment> appointmentList = new ArrayList<Appointment>();
// Constructor // Constructor
public Student(String username, String fullname, long npm, UserList userList) { public Student(String username, String fullname, long npm, UserList userList) {
this.username = username; this.setUsername(username);
this.fullname = fullname; this.setFullname(fullname);
this.role = "S"; this.setRole("S");
this.npm = npm; this.setNPM(npm);
// Register new TA to the userList // Register new TA to the userList
userList.userList.add(this); userList.userList.add(this);
...@@ -32,7 +27,6 @@ public class Student extends UserStudent { ...@@ -32,7 +27,6 @@ public class Student extends UserStudent {
System.out.println("TA not found"); System.out.println("TA not found");
} else { } else {
Appointment newAppointment = new Appointment(date, this, ta, startTime, endTime, description); Appointment newAppointment = new Appointment(date, this, ta, startTime, endTime, description);
//this.calendar.addAppointment(day, newAppointment);
this.appointmentList.add(newAppointment); this.appointmentList.add(newAppointment);
ta.getAppointmentList().add(newAppointment); ta.getAppointmentList().add(newAppointment);
} }
...@@ -44,19 +38,6 @@ public class Student extends UserStudent { ...@@ -44,19 +38,6 @@ public class Student extends UserStudent {
ta.seeCalendar(); ta.seeCalendar();
} }
public String getRole() {
return role;
}
public String getUsername() {
return username;
}
public String toString() {
return username + " - " + fullname;
}
public ArrayList<Appointment> getAppointmentList() { public ArrayList<Appointment> getAppointmentList() {
return this.appointmentList; return this.appointmentList;
} }
......
...@@ -8,20 +8,16 @@ import softeng.g4.calendar.Schedule; ...@@ -8,20 +8,16 @@ import softeng.g4.calendar.Schedule;
import java.util.ArrayList; import java.util.ArrayList;
public class TeachingAssistant extends UserStudent { public class TeachingAssistant extends UserStudent {
private String username;
private String fullname;
private String role;
private long npm;
private Admin askPermissionAdmin = null; private Admin askPermissionAdmin = null;
private Calendar calendar = new Calendar(); private Calendar calendar = new Calendar();
private ArrayList<Appointment> appointmentList = new ArrayList<Appointment>(); private ArrayList<Appointment> appointmentList = new ArrayList<Appointment>();
// Constructor // Constructor
public TeachingAssistant(String username, String fullname, long npm, UserList userList) { public TeachingAssistant(String username, String fullname, long npm, UserList userList) {
this.username = username; this.setUsername(username);
this.fullname = fullname; this.setFullname(fullname);
this.role = "TA"; this.setRole("TA");
this.npm = npm; this.setNPM(npm);
// Register new TA to the userList // Register new TA to the userList
userList.userList.add(this); userList.userList.add(this);
...@@ -107,18 +103,6 @@ public class TeachingAssistant extends UserStudent { ...@@ -107,18 +103,6 @@ public class TeachingAssistant extends UserStudent {
this.calendar.switchPermission(); this.calendar.switchPermission();
} }
public String toString() {
return username + " - " + fullname;
}
public String getRole() {
return role;
}
public String getUsername() {
return username;
}
public Calendar getCalendar() { public Calendar getCalendar() {
return calendar; return calendar;
} }
......
...@@ -3,6 +3,7 @@ package softeng.g4.user; ...@@ -3,6 +3,7 @@ package softeng.g4.user;
import java.io.Serializable; import java.io.Serializable;
public abstract class User implements Serializable { public abstract class User implements Serializable {
private String fullname;
private String username; private String username;
private String role; private String role;
...@@ -13,4 +14,24 @@ public abstract class User implements Serializable { ...@@ -13,4 +14,24 @@ public abstract class User implements Serializable {
public String getUsername() { public String getUsername() {
return username; return username;
} }
public void setUsername(String username) {
this.username = username;
}
public void setRole(String role) {
this.role = role;
}
public String getFullname() {
return fullname;
}
public void setFullname(String fullname) {
this.fullname = fullname;
}
public String toString() {
return username + " - " + fullname;
}
} }
package softeng.g4.user; package softeng.g4.user;
public abstract class UserStudent extends User{ public abstract class UserStudent extends User {
private long npm; private long npm;
public long getNPM() {
return npm;
}
public void setNPM(long npm) {
this.npm = npm;
}
} }
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