Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
G4-SoftEng
Group4-SoftEng
Commits
a5844345
Commit
a5844345
authored
Jun 06, 2021
by
saddamonpc
Browse files
Refactor Student.java and Add more tests for TeachingAssistant.java
parent
fc7f0dd1
Pipeline
#81531
failed with stage
in 1 minute and 14 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/softeng/g4/appointment/Appointment.java
View file @
a5844345
...
@@ -14,17 +14,22 @@ public class Appointment implements Serializable {
...
@@ -14,17 +14,22 @@ public class Appointment implements Serializable {
private
String
startTime
;
private
String
startTime
;
private
String
endTime
;
private
String
endTime
;
private
String
description
;
private
String
description
;
public
String
getStatus
()
{
return
status
;
}
private
String
status
;
private
String
status
;
public
Appointment
(
String
date
,
Student
student
,
TeachingAssistant
ta
,
String
startTime
,
String
endTime
,
String
decription
,
String
status
)
{
public
Appointment
(
String
date
,
Student
student
,
TeachingAssistant
ta
,
String
startTime
,
String
endTime
,
String
de
s
cription
)
{
this
.
id
=
generateId
();
this
.
id
=
generateId
();
this
.
date
=
date
;
this
.
date
=
date
;
this
.
student
=
student
;
this
.
student
=
student
;
this
.
ta
=
ta
;
this
.
ta
=
ta
;
this
.
startTime
=
startTime
;
this
.
startTime
=
startTime
;
this
.
endTime
=
endTime
;
this
.
endTime
=
endTime
;
this
.
description
=
decription
;
this
.
description
=
de
s
cription
;
this
.
status
=
status
;
this
.
status
=
"Pending"
;
}
}
public
String
getId
(){
public
String
getId
(){
...
...
src/main/java/softeng/g4/calendar/Calendar.java
View file @
a5844345
...
@@ -13,13 +13,6 @@ public class Calendar implements Serializable {
...
@@ -13,13 +13,6 @@ public class Calendar implements Serializable {
private
ArrayList
<
Schedule
>
friday
=
new
ArrayList
<
Schedule
>();
private
ArrayList
<
Schedule
>
friday
=
new
ArrayList
<
Schedule
>();
private
ArrayList
<
Schedule
>
saturday
=
new
ArrayList
<
Schedule
>();
private
ArrayList
<
Schedule
>
saturday
=
new
ArrayList
<
Schedule
>();
private
ArrayList
<
Schedule
>
sunday
=
new
ArrayList
<
Schedule
>();
private
ArrayList
<
Schedule
>
sunday
=
new
ArrayList
<
Schedule
>();
// private ArrayList<Appointment> A_monday = new ArrayList<>();
// private ArrayList<Appointment> A_tuesday = new ArrayList<>();
// private ArrayList<Appointment> A_wednesday = new ArrayList<>();
// private ArrayList<Appointment> A_thursday = new ArrayList<>();
// private ArrayList<Appointment> A_friday = new ArrayList<>();
// private ArrayList<Appointment> A_saturday = new ArrayList<>();
// private ArrayList<Appointment> A_sunday = new ArrayList<>();
public
void
showCalendar
()
{
public
void
showCalendar
()
{
System
.
out
.
println
(
"Monday:"
);
System
.
out
.
println
(
"Monday:"
);
...
@@ -50,7 +43,7 @@ public class Calendar implements Serializable {
...
@@ -50,7 +43,7 @@ public class Calendar implements Serializable {
for
(
Schedule
schedule
:
sunday
)
{
for
(
Schedule
schedule
:
sunday
)
{
System
.
out
.
println
(
schedule
.
toString
());
System
.
out
.
println
(
schedule
.
toString
());
}
}
System
.
out
.
println
(
""
);
System
.
out
.
println
();
}
}
// Add schedule to calendar
// Add schedule to calendar
...
@@ -84,9 +77,8 @@ public class Calendar implements Serializable {
...
@@ -84,9 +77,8 @@ public class Calendar implements Serializable {
sunday
.
add
(
schedule
);
sunday
.
add
(
schedule
);
break
;
break
;
// TODO: Need to change default case
default
:
default
:
monday
.
add
(
schedule
);
System
.
out
.
println
(
"Wrong day!"
);
break
;
break
;
}
}
}
}
...
@@ -119,41 +111,4 @@ public class Calendar implements Serializable {
...
@@ -119,41 +111,4 @@ public class Calendar implements Serializable {
return
sunday
;
return
sunday
;
}
}
// Add Appointment to calendar
// public void addAppointment(String day, Appointment appointment) {
// switch (day) {
// case "monday":
// A_monday.add(appointment);
// break;
//
// case "tuesday":
// A_tuesday.add(appointment);
// break;
//
// case "wednesday":
// A_wednesday.add(appointment);
// break;
//
// case "thursday":
// A_thursday.add(appointment);
// break;
//
// case "friday":
// A_friday.add(appointment);
// break;
//
// case "saturday":
// A_saturday.add(appointment);
// break;
//
// case "sunday":
// A_sunday.add(appointment);
// break;
//
// // TODO: Need to change default case
// default:
// A_monday.add(appointment);
// break;
// }
// }
}
}
src/main/java/softeng/g4/cli/StudentCLI.java
View file @
a5844345
...
@@ -39,8 +39,7 @@ public class StudentCLI extends CLI {
...
@@ -39,8 +39,7 @@ public class StudentCLI extends CLI {
String
endTime
=
sc
.
nextLine
();
String
endTime
=
sc
.
nextLine
();
System
.
out
.
println
(
"(Optional) Add description for your appointment: "
);
System
.
out
.
println
(
"(Optional) Add description for your appointment: "
);
String
description
=
sc
.
nextLine
();
String
description
=
sc
.
nextLine
();
String
status
=
"Pending"
;
currentStudent
.
setAppointment
(
day
,
ta
,
startTime
,
endTime
,
description
,
userList
);
currentStudent
.
setAppointment
(
day
,
ta
,
startTime
,
endTime
,
description
,
status
,
userList
);
System
.
out
.
println
(
"Successfully added a new appointment!"
);
System
.
out
.
println
(
"Successfully added a new appointment!"
);
break
;
break
;
...
...
src/main/java/softeng/g4/user/Student.java
View file @
a5844345
...
@@ -26,25 +26,17 @@ public class Student extends UserStudent {
...
@@ -26,25 +26,17 @@ public class Student extends UserStudent {
}
}
// TODO: Adds appointment with the corresponding TeachingAssistant
// TODO: Adds appointment with the corresponding TeachingAssistant
public
void
setAppointment
(
String
date
,
String
TAusername
,
String
startTime
,
String
endTime
,
String
description
,
String
status
,
UserList
userList
)
{
public
void
setAppointment
(
String
date
,
String
TAusername
,
String
startTime
,
String
endTime
,
String
description
,
UserList
userList
)
{
TeachingAssistant
ta
=
userList
.
searchTA
(
TAusername
);
TeachingAssistant
ta
=
userList
.
searchTA
(
TAusername
);
if
(
ta
.
getUsername
().
equals
(
"falseTA"
)){
if
(
ta
.
getUsername
().
equals
(
"falseTA"
)){
System
.
out
.
println
(
"TA not found"
);
System
.
out
.
println
(
"TA not found"
);
}
else
{
}
else
{
Appointment
newAppointment
=
new
Appointment
(
date
,
this
,
ta
,
startTime
,
endTime
,
description
,
status
);
Appointment
newAppointment
=
new
Appointment
(
date
,
this
,
ta
,
startTime
,
endTime
,
description
);
//this.calendar.addAppointment(day, newAppointment);
//this.calendar.addAppointment(day, newAppointment);
this
.
appointmentlist
.
add
(
newAppointment
);
this
.
appointmentlist
.
add
(
newAppointment
);
ta
.
appointmentlist
.
add
(
newAppointment
);
ta
.
appointmentlist
.
add
(
newAppointment
);
}
}
}
}
public
void
addAppointment
()
{
}
// Not a necessary method to implement. Just a bonus if there's enough time.
public
void
addReminder
()
{}
// TODO: After adding appointment, the student will have an option to add a description or not.
public
void
addDescription
()
{}
// See this Student's calendar
// See this Student's calendar
// temporary calendar
// temporary calendar
...
...
src/main/java/softeng/g4/user/TeachingAssistant.java
View file @
a5844345
...
@@ -37,11 +37,6 @@ public class TeachingAssistant extends UserStudent {
...
@@ -37,11 +37,6 @@ public class TeachingAssistant extends UserStudent {
this
.
calendar
.
addSchedule
(
day
,
newSchedule
);
this
.
calendar
.
addSchedule
(
day
,
newSchedule
);
}
}
// public void setAppointment(String day, String name, String ta, String startTime, String endTime, String description, String status) {
// Appointment newAppointment = new Appointment(name, ta, startTime, endTime, description, status);
// this.calendar.addAppointment(day, newAppointment);
// }
// See this TA's calendar
// See this TA's calendar
public
void
seeCalendar
()
{
public
void
seeCalendar
()
{
this
.
calendar
.
showCalendar
();
this
.
calendar
.
showCalendar
();
...
@@ -89,9 +84,6 @@ public class TeachingAssistant extends UserStudent {
...
@@ -89,9 +84,6 @@ public class TeachingAssistant extends UserStudent {
}
}
}
}
// Not a necessary method to implement. Just a bonus if there's enough time.
public
void
addReminder
()
{}
public
String
toString
()
{
public
String
toString
()
{
return
username
+
" - "
+
fullname
;
return
username
+
" - "
+
fullname
;
}
}
...
...
src/test/java/softeng/g4/user/TeachingAssistantTest.java
View file @
a5844345
package
softeng.g4.user
;
package
softeng.g4.user
;
import
org.junit.jupiter.api.AfterEach
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
softeng.g4.course.CourseList
;
import
softeng.g4.course.CourseList
;
import
java.io.ByteArrayOutputStream
;
import
java.io.PrintStream
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
class
TeachingAssistantTest
{
class
TeachingAssistantTest
{
private
UserList
userList
=
new
UserList
();
private
UserList
userList
;
private
CourseList
courseList
=
new
CourseList
();
private
CourseList
courseList
;
private
TeachingAssistant
testTa
=
private
Admin
testAdmin
;
new
TeachingAssistant
(
"testTa"
,
"Test Teacher"
,
Long
.
parseLong
(
"123456789"
),
userList
);
private
TeachingAssistant
testTa
;
private
Student
testStudent
;
@Test
@BeforeEach
void
seeCourseList
()
{
void
setUpTearDown
()
{
userList
=
new
UserList
();
courseList
=
new
CourseList
();
testAdmin
=
new
Admin
(
"falseAdmin"
,
"False Admin"
,
userList
);
testTa
=
new
TeachingAssistant
(
"testTa"
,
"Test Teacher"
,
Long
.
parseLong
(
"123456789"
),
userList
);
testStudent
=
new
Student
(
"testStudent"
,
"Test Student"
,
Long
.
valueOf
(
"123456789"
),
userList
);
}
}
@Test
@Test
void
setSchedule
()
{
void
setSchedule
()
{
testTa
.
setSchedule
(
"monday"
,
"Busy"
,
"07:00"
,
"21:00"
);
testTa
.
setSchedule
(
"tuesday"
,
"Busy"
,
"07:00"
,
"21:00"
);
testTa
.
setSchedule
(
"wednesday"
,
"Busy"
,
"07:00"
,
"21:00"
);
testTa
.
setSchedule
(
"thursday"
,
"Busy"
,
"07:00"
,
"21:00"
);
testTa
.
setSchedule
(
"friday"
,
"Busy"
,
"07:00"
,
"21:00"
);
testTa
.
setSchedule
(
"saturday"
,
"Busy"
,
"07:00"
,
"21:00"
);
testTa
.
setSchedule
(
"saturday"
,
"Busy"
,
"07:00"
,
"21:00"
);
testTa
.
setSchedule
(
"sunday"
,
"Busy"
,
"07:00"
,
"21:00"
);
assertEquals
(
testTa
.
getCalendar
().
getMonday
().
size
(),
1
);
assertEquals
(
testTa
.
getCalendar
().
getTuesday
().
size
(),
1
);
assertEquals
(
testTa
.
getCalendar
().
getWednesday
().
size
(),
1
);
assertEquals
(
testTa
.
getCalendar
().
getThursday
().
size
(),
1
);
assertEquals
(
testTa
.
getCalendar
().
getFriday
().
size
(),
1
);
assertEquals
(
testTa
.
getCalendar
().
getSaturday
().
size
(),
1
);
assertEquals
(
testTa
.
getCalendar
().
getSaturday
().
size
(),
1
);
assertEquals
(
testTa
.
getCalendar
().
getSunday
().
size
(),
1
);
}
}
@Test
@Test
void
seeCalendar
()
{
void
seeCalendar
()
throws
Exception
{
}
ByteArrayOutputStream
outContent
=
new
ByteArrayOutputStream
();
System
.
setOut
(
new
PrintStream
(
outContent
));
// After this all System.out.println() statements will come to outContent stream.
@Test
testTa
.
setSchedule
(
"monday"
,
"Busy"
,
"07:00"
,
"21:00"
);
void
acceptAppointment
()
{
}
@Test
testTa
.
seeCalendar
();
void
rejectAppointment
()
{
String
expectedOutput
=
"Monday:\r\nBusy 07:00 - 21:00\r\n"
+
"Tuesday:\r\nWednesday:\r\nThursday:\r\nFriday:\r\nSaturday:\r\nSunday:\r\n\r\n"
;
assertEquals
(
expectedOutput
,
outContent
.
toString
());
}
}
@Test
@Test
void
addReminder
()
{
void
acceptAppointment
()
{
}
testStudent
.
setAppointment
(
"31/12"
,
"testTa"
,
"08:00"
,
"09:40"
,
"testDesc"
,
userList
);
@Test
testTa
.
acceptAppointment
(
testTa
.
appointmentlist
.
get
(
0
).
getId
(),
userList
);
void
testToString
()
{
assertEquals
(
testTa
.
appointmentlist
.
get
(
0
).
getStatus
(),
"Accepted"
);
assertEquals
(
testStudent
.
appointmentlist
.
get
(
0
).
getStatus
(),
"Accepted"
);
}
}
@Test
@Test
void
getRole
()
{
void
rejectAppointment
()
{
testStudent
.
setAppointment
(
"31/12"
,
"testTa"
,
"08:00"
,
"09:40"
,
"testDesc"
,
userList
);
testTa
.
rejectAppointment
(
testTa
.
appointmentlist
.
get
(
0
).
getId
(),
userList
);
assertEquals
(
testTa
.
appointmentlist
.
get
(
0
).
getStatus
(),
"Rejected"
);
assertEquals
(
testStudent
.
appointmentlist
.
get
(
0
).
getStatus
(),
"Rejected"
);
}
}
@Test
void
getUsername
()
{
}
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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