Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
G4-SoftEng
Group4-SoftEng
Commits
de372331
Commit
de372331
authored
Jun 22, 2021
by
saddamonpc
Browse files
Move appointmentList in Student and TeachingAssistant to its superclass UserStudent
parent
d1ad93da
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/main/java/softeng/g4/Main.java
View file @
de372331
...
...
@@ -20,7 +20,7 @@ public class Main {
UserList
userList
;
// --------Uncomment this for the "hardcoded" version.
reset
();
//
reset();
while
(
true
)
{
...
...
src/main/java/softeng/g4/user/Student.java
View file @
de372331
...
...
@@ -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
.
a
ppointmentList
.
add
(
newAppointment
);
this
.
getA
ppointmentList
()
.
add
(
newAppointment
);
ta
.
getAppointmentList
().
add
(
newAppointment
);
}
}
public
ArrayList
<
Appointment
>
getAppointmentList
()
{
return
this
.
appointmentList
;
}
}
src/main/java/softeng/g4/user/TeachingAssistant.java
View file @
de372331
...
...
@@ -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
:
a
ppointmentList
)
{
for
(
Appointment
appointment
:
this
.
getA
ppointmentList
()
)
{
if
(
appointment
.
getId
().
equals
(
id
))
{
found
=
true
;
appointment
.
setStatus
(
"Accepted"
);
Student
student
=
userList
.
searchStudent
(
appointment
.
getStudent
().
getUsername
());
for
(
Appointment
student
a
ppointment
:
student
.
getAppointmentList
())
{
if
(
student
a
ppointment
.
getId
().
equals
(
id
))
{
student
a
ppointment
.
setStatus
(
"Accepted"
);
for
(
Appointment
student
A
ppointment
:
student
.
getAppointmentList
())
{
if
(
student
A
ppointment
.
getId
().
equals
(
id
))
{
student
A
ppointment
.
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
:
a
ppointmentList
)
{
for
(
Appointment
appointment
:
this
.
getA
ppointmentList
()
)
{
if
(
appointment
.
getId
().
equals
(
id
))
{
found
=
true
;
appointment
.
setStatus
(
"Rejected"
);
Student
student
=
userList
.
searchStudent
(
appointment
.
getStudent
().
getUsername
());
for
(
Appointment
student
a
ppointment
:
student
.
getAppointmentList
())
{
if
(
student
a
ppointment
.
getId
().
equals
(
id
))
{
student
a
ppointment
.
setStatus
(
"Rejected"
);
for
(
Appointment
student
A
ppointment
:
student
.
getAppointmentList
())
{
if
(
student
A
ppointment
.
getId
().
equals
(
id
))
{
student
A
ppointment
.
setStatus
(
"Rejected"
);
}
}
}
...
...
@@ -103,8 +102,4 @@ public class TeachingAssistant extends UserStudent {
public
Calendar
getCalendar
()
{
return
calendar
;
}
public
ArrayList
<
Appointment
>
getAppointmentList
()
{
return
this
.
appointmentList
;
}
}
src/main/java/softeng/g4/user/UserStudent.java
View file @
de372331
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
;
}
}
src/main/java/softeng/g4/userlist.txt
View file @
de372331
No preview for this file type
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment