Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
agile-java
/
AgileJavaAndroid
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ce57dcf8
authored
May 31, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small refactoring in Lesson 6
parent
d478a696
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
12 deletions
app/src/main/java/com/example/paktalin/agilejava/Session.java
app/src/main/java/com/example/paktalin/agilejava/summer/SummerCourseSession.java
app/src/test/java/com/example/paktalin/agilejava/CourseSessionTest.java
app/src/test/java/com/example/paktalin/agilejava/SessionTest.java
app/src/test/java/com/example/paktalin/agilejava/SummerCourseSessionTest.java
app/src/main/java/com/example/paktalin/agilejava/Session.java
View file @
ce57dcf8
...
@@ -34,16 +34,16 @@ public abstract class Session implements Comparable<Session>{
...
@@ -34,16 +34,16 @@ public abstract class Session implements Comparable<Session>{
return
this
.
getNumber
().
compareTo
(
that
.
getNumber
());
return
this
.
getNumber
().
compareTo
(
that
.
getNumber
());
}
}
protected
void
setNumberOfCredits
(
int
numberOfCredits
)
{
void
setNumberOfCredits
(
int
numberOfCredits
)
{
this
.
numberOfCredits
=
numberOfCredits
;
this
.
numberOfCredits
=
numberOfCredits
;
}
}
public
void
enroll
(
Student
student
)
{
void
enroll
(
Student
student
)
{
students
.
add
(
student
);
students
.
add
(
student
);
student
.
addCredits
(
numberOfCredits
);
student
.
addCredits
(
numberOfCredits
);
}
}
public
Date
getEndDate
()
{
Date
getEndDate
()
{
GregorianCalendar
calendar
=
new
GregorianCalendar
();
GregorianCalendar
calendar
=
new
GregorianCalendar
();
calendar
.
setTime
(
getStartDate
());
calendar
.
setTime
(
getStartDate
());
calendar
.
add
(
Calendar
.
DAY_OF_YEAR
,
getNumberOfDaysInSession
());
calendar
.
add
(
Calendar
.
DAY_OF_YEAR
,
getNumberOfDaysInSession
());
...
@@ -56,7 +56,7 @@ public abstract class Session implements Comparable<Session>{
...
@@ -56,7 +56,7 @@ public abstract class Session implements Comparable<Session>{
return
getSessionLength
()
*
daysInWeek
-
daysFromFridayToMonday
;
return
getSessionLength
()
*
daysInWeek
-
daysFromFridayToMonday
;
}
}
public
List
<
Student
>
getAllStudents
()
{
List
<
Student
>
getAllStudents
()
{
return
students
;
return
students
;
}
}
...
@@ -68,10 +68,10 @@ public abstract class Session implements Comparable<Session>{
...
@@ -68,10 +68,10 @@ public abstract class Session implements Comparable<Session>{
int
getNumberOfStudents
()
{
int
getNumberOfStudents
()
{
return
students
.
size
();
return
students
.
size
();
}
}
public
String
getDepartment
()
{
String
getDepartment
()
{
return
department
;
return
department
;
}
}
public
String
getNumber
()
{
String
getNumber
()
{
return
number
;
return
number
;
}
}
Student
get
(
int
index
)
{
Student
get
(
int
index
)
{
...
...
app/src/main/java/com/example/paktalin/agilejava/summer/SummerCourseSession.java
View file @
ce57dcf8
...
@@ -36,4 +36,4 @@ public class SummerCourseSession extends Session {
...
@@ -36,4 +36,4 @@ public class SummerCourseSession extends Session {
protected
int
getSessionLength
()
{
protected
int
getSessionLength
()
{
return
8
;
return
8
;
}
}
}
}
\ No newline at end of file
app/src/test/java/com/example/paktalin/agilejava/CourseSessionTest.java
View file @
ce57dcf8
...
@@ -22,7 +22,7 @@ public class CourseSessionTest extends SessionTest {
...
@@ -22,7 +22,7 @@ public class CourseSessionTest extends SessionTest {
}
}
@Override
@Override
protected
Date
calculate
EndDate
()
{
protected
Date
getExpected
EndDate
()
{
return
DateUtil
.
createDate
(
2003
,
4
,
25
);
return
DateUtil
.
createDate
(
2003
,
4
,
25
);
}
}
}
}
app/src/test/java/com/example/paktalin/agilejava/SessionTest.java
View file @
ce57dcf8
...
@@ -22,6 +22,7 @@ abstract public class SessionTest extends TestCase {
...
@@ -22,6 +22,7 @@ abstract public class SessionTest extends TestCase {
}
}
protected
abstract
Session
createSession
(
String
department
,
String
number
,
Date
startDate
);
protected
abstract
Session
createSession
(
String
department
,
String
number
,
Date
startDate
);
protected
abstract
Date
getExpectedEndDate
();
public
void
testCreate
()
{
public
void
testCreate
()
{
assertEquals
(
"ENGL"
,
session
.
getDepartment
());
assertEquals
(
"ENGL"
,
session
.
getDepartment
());
...
@@ -62,8 +63,6 @@ abstract public class SessionTest extends TestCase {
...
@@ -62,8 +63,6 @@ abstract public class SessionTest extends TestCase {
public
void
testCourseDates
()
{
public
void
testCourseDates
()
{
Date
startDate
=
DateUtil
.
createDate
(
2003
,
1
,
6
);
Date
startDate
=
DateUtil
.
createDate
(
2003
,
1
,
6
);
Session
session
=
createSession
(
"ENGL"
,
"200"
,
startDate
);
Session
session
=
createSession
(
"ENGL"
,
"200"
,
startDate
);
assertEquals
(
calculate
EndDate
(),
session
.
getEndDate
());
assertEquals
(
getExpected
EndDate
(),
session
.
getEndDate
());
}
}
protected
abstract
Date
calculateEndDate
();
}
}
app/src/test/java/com/example/paktalin/agilejava/SummerCourseSessionTest.java
View file @
ce57dcf8
...
@@ -24,7 +24,7 @@ public class SummerCourseSessionTest extends SessionTest {
...
@@ -24,7 +24,7 @@ public class SummerCourseSessionTest extends SessionTest {
}
}
@Override
@Override
protected
Date
calculate
EndDate
()
{
protected
Date
getExpected
EndDate
()
{
return
DateUtil
.
createDate
(
2003
,
2
,
28
);
return
DateUtil
.
createDate
(
2003
,
2
,
28
);
}
}
...
...
Write
Preview
Markdown
is supported
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