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
f20ab55b
authored
May 17, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lesson 3 is done
parent
0f8d14f1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
10 deletions
app/src/main/java/com/example/paktalin/agilejava/DateUtil.java
app/src/main/java/com/example/paktalin/agilejava/RosterReporter.java
app/src/test/java/com/example/paktalin/agilejava/CourseSessionTest.java
app/src/test/java/com/example/paktalin/agilejava/RosterReporterTest.java
app/src/main/java/com/example/paktalin/agilejava/DateUtil.java
View file @
f20ab55b
...
@@ -10,7 +10,7 @@ import java.util.GregorianCalendar;
...
@@ -10,7 +10,7 @@ import java.util.GregorianCalendar;
class
DateUtil
{
class
DateUtil
{
Date
createDate
(
int
year
,
int
month
,
int
date
)
{
static
Date
createDate
(
int
year
,
int
month
,
int
date
)
{
GregorianCalendar
calendar
=
new
GregorianCalendar
();
GregorianCalendar
calendar
=
new
GregorianCalendar
();
calendar
.
clear
();
calendar
.
clear
();
calendar
.
set
(
Calendar
.
YEAR
,
year
);
calendar
.
set
(
Calendar
.
YEAR
,
year
);
...
...
app/src/main/java/com/example/paktalin/agilejava/RosterReporter.java
View file @
f20ab55b
...
@@ -7,29 +7,38 @@ package com.example.paktalin.agilejava;
...
@@ -7,29 +7,38 @@ package com.example.paktalin.agilejava;
class
RosterReporter
{
class
RosterReporter
{
static
final
String
NEW_LINE
=
System
.
getProperty
(
"line.separator"
);
static
final
String
NEW_LINE
=
System
.
getProperty
(
"line.separator"
);
static
String
ROSTER_REPORT_HEADER
=
"Student"
+
NEW_LINE
+
static
String
ROSTER_REPORT_HEADER
=
"Student"
+
NEW_LINE
+
"_____"
+
NEW_LINE
;
"_____"
+
NEW_LINE
;
static
String
ROSTER_REPORT_FOOTER
=
NEW_LINE
+
"# students = "
;
static
String
ROSTER_REPORT_FOOTER
=
NEW_LINE
+
"# students = "
;
private
CourseSession
session
;
private
CourseSession
session
;
private
StringBuilder
buffer
;
RosterReporter
(
CourseSession
session
)
{
RosterReporter
(
CourseSession
session
)
{
this
.
session
=
session
;
this
.
session
=
session
;
}
}
String
getReport
()
{
buffer
=
new
StringBuilder
();
writeHeader
();
writeBody
();
writeFooter
();
String
getReport
()
{
return
buffer
.
toString
();
StringBuilder
buffer
=
new
StringBuilder
();
}
private
void
writeHeader
()
{
buffer
.
append
(
ROSTER_REPORT_HEADER
);
buffer
.
append
(
ROSTER_REPORT_HEADER
);
}
private
void
writeBody
()
{
for
(
Student
student
:
session
.
getAllStudents
())
{
for
(
Student
student
:
session
.
getAllStudents
())
{
buffer
.
append
(
student
.
getName
());
buffer
.
append
(
student
.
getName
());
buffer
.
append
(
NEW_LINE
);
buffer
.
append
(
NEW_LINE
);
}
}
}
private
void
writeFooter
()
{
buffer
.
append
(
ROSTER_REPORT_FOOTER
+
session
.
getAllStudents
().
size
()
+
NEW_LINE
);
buffer
.
append
(
ROSTER_REPORT_FOOTER
+
session
.
getAllStudents
().
size
()
+
NEW_LINE
);
return
buffer
.
toString
();
}
}
}
}
app/src/test/java/com/example/paktalin/agilejava/CourseSessionTest.java
View file @
f20ab55b
...
@@ -14,7 +14,7 @@ public class CourseSessionTest extends TestCase {
...
@@ -14,7 +14,7 @@ public class CourseSessionTest extends TestCase {
private
Date
startDate
;
private
Date
startDate
;
public
void
setUp
()
{
public
void
setUp
()
{
startDate
=
new
DateUtil
()
.
createDate
(
2003
,
1
,
6
);
startDate
=
DateUtil
.
createDate
(
2003
,
1
,
6
);
session
=
new
CourseSession
(
"ENGL"
,
"101"
,
startDate
);
session
=
new
CourseSession
(
"ENGL"
,
"101"
,
startDate
);
}
}
...
@@ -38,7 +38,7 @@ public class CourseSessionTest extends TestCase {
...
@@ -38,7 +38,7 @@ public class CourseSessionTest extends TestCase {
}
}
public
void
testCourseDates
()
{
public
void
testCourseDates
()
{
Date
sixteenWeeksOut
=
new
DateUtil
()
.
createDate
(
2003
,
4
,
25
);
Date
sixteenWeeksOut
=
DateUtil
.
createDate
(
2003
,
4
,
25
);
assertEquals
(
sixteenWeeksOut
,
session
.
getEndDate
());
assertEquals
(
sixteenWeeksOut
,
session
.
getEndDate
());
}
}
}
}
app/src/test/java/com/example/paktalin/agilejava/RosterReporterTest.java
View file @
f20ab55b
...
@@ -11,12 +11,14 @@ public class RosterReporterTest extends TestCase {
...
@@ -11,12 +11,14 @@ public class RosterReporterTest extends TestCase {
public
void
testRosterReport
()
{
public
void
testRosterReport
()
{
CourseSession
session
=
new
CourseSession
(
"ENGL"
,
"101"
,
CourseSession
session
=
new
CourseSession
(
"ENGL"
,
"101"
,
new
DateUtil
()
.
createDate
(
2003
,
1
,
6
));
DateUtil
.
createDate
(
2003
,
1
,
6
));
session
.
enroll
(
new
Student
(
"A"
));
session
.
enroll
(
new
Student
(
"A"
));
session
.
enroll
(
new
Student
(
"B"
));
session
.
enroll
(
new
Student
(
"B"
));
String
rosterReport
=
new
RosterReporter
(
session
).
getReport
();
String
rosterReport
=
new
RosterReporter
(
session
).
getReport
();
System
.
out
.
println
(
rosterReport
);
assertEquals
(
assertEquals
(
RosterReporter
.
ROSTER_REPORT_HEADER
+
RosterReporter
.
ROSTER_REPORT_HEADER
+
"A"
+
RosterReporter
.
NEW_LINE
+
"A"
+
RosterReporter
.
NEW_LINE
+
...
...
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