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