Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit ad07f9e7 authored by saddamonpc's avatar saddamonpc
Browse files

Change strategy variable

parent fc82964d
No related branches found
No related tags found
1 merge request!9Refactor Calendar Module
......@@ -20,7 +20,7 @@ public class Main {
UserList userList;
// --------Uncomment this for the "hardcoded" version.
// reset();
reset();
while (true) {
......
......@@ -13,7 +13,7 @@ public class Admin extends User {
this.username = username;
this.fullname = fullname;
this.role = "A";
this.setStrategy(new SeeCalendarCheckPermission());
this.setSeeCalendarStrategy(new SeeCalendarCheckPermission());
// Register new Admin to the userList
userList.userList.add(this);
......
package softeng.g4.user;
import softeng.g4.calendar.Calendar;
import softeng.g4.calendar.Schedule;
import softeng.g4.appointment.Appointment;
import softeng.g4.calendar.SeeCalendarWithoutPermission;
import java.util.ArrayList;
public class Student extends UserStudent {
// Constructor
......@@ -15,7 +11,7 @@ public class Student extends UserStudent {
this.setFullname(fullname);
this.setRole("S");
this.setNPM(npm);
this.setStrategy(new SeeCalendarWithoutPermission());
this.setSeeCalendarStrategy(new SeeCalendarWithoutPermission());
// Register new TA to the userList
userList.userList.add(this);
......
......@@ -6,8 +6,6 @@ import softeng.g4.course.CourseList;
import softeng.g4.calendar.Calendar;
import softeng.g4.calendar.Schedule;
import java.util.ArrayList;
public class TeachingAssistant extends UserStudent {
private Admin askPermissionAdmin = null;
private Calendar calendar = new Calendar();
......@@ -18,7 +16,7 @@ public class TeachingAssistant extends UserStudent {
this.setFullname(fullname);
this.setRole("TA");
this.setNPM(npm);
this.setStrategy(new SeeCalendarWithoutPermission());
this.setSeeCalendarStrategy(new SeeCalendarWithoutPermission());
// Register new TA to the userList
userList.userList.add(this);
......
......@@ -8,10 +8,10 @@ public abstract class User implements Serializable {
private String fullname;
private String username;
private String role;
private SeeCalendarStrategy strategy;
private SeeCalendarStrategy seeCalendarStrategy;
public void seeCalendar(String username, UserList userList) {
strategy.seeCalendar(username, userList);
seeCalendarStrategy.seeCalendar(username, userList);
}
public String getRole() {
......@@ -42,7 +42,7 @@ public abstract class User implements Serializable {
return username + " - " + fullname;
}
public void setStrategy(SeeCalendarStrategy strategy) {
this.strategy = strategy;
public void setSeeCalendarStrategy(SeeCalendarStrategy seeCalendarStrategy) {
this.seeCalendarStrategy = seeCalendarStrategy;
}
}
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment