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;
class
DateUtil
{
Date
createDate
(
int
year
,
int
month
,
int
date
)
{
static
Date
createDate
(
int
year
,
int
month
,
int
date
)
{
GregorianCalendar
calendar
=
new
GregorianCalendar
();
calendar
.
clear
();
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;
class
RosterReporter
{
static
final
String
NEW_LINE
=
System
.
getProperty
(
"line.separator"
);
static
String
ROSTER_REPORT_HEADER
=
"Student"
+
NEW_LINE
+
"_____"
+
NEW_LINE
;
static
String
ROSTER_REPORT_HEADER
=
"Student"
+
NEW_LINE
+
"_____"
+
NEW_LINE
;
static
String
ROSTER_REPORT_FOOTER
=
NEW_LINE
+
"# students = "
;
private
CourseSession
session
;
private
StringBuilder
buffer
;
RosterReporter
(
CourseSession
session
)
{
this
.
session
=
session
;
}
String
getReport
()
{
buffer
=
new
StringBuilder
();
writeHeader
();
writeBody
();
writeFooter
();
String
getReport
()
{
StringBuilder
buffer
=
new
StringBuilder
();
return
buffer
.
toString
();
}
private
void
writeHeader
()
{
buffer
.
append
(
ROSTER_REPORT_HEADER
);
}
private
void
writeBody
()
{
for
(
Student
student
:
session
.
getAllStudents
())
{
buffer
.
append
(
student
.
getName
());
buffer
.
append
(
NEW_LINE
);
}
}
private
void
writeFooter
()
{
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 {
private
Date
startDate
;
public
void
setUp
()
{
startDate
=
new
DateUtil
()
.
createDate
(
2003
,
1
,
6
);
startDate
=
DateUtil
.
createDate
(
2003
,
1
,
6
);
session
=
new
CourseSession
(
"ENGL"
,
"101"
,
startDate
);
}
...
...
@@ -38,7 +38,7 @@ public class CourseSessionTest extends TestCase {
}
public
void
testCourseDates
()
{
Date
sixteenWeeksOut
=
new
DateUtil
()
.
createDate
(
2003
,
4
,
25
);
Date
sixteenWeeksOut
=
DateUtil
.
createDate
(
2003
,
4
,
25
);
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 {
public
void
testRosterReport
()
{
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
(
"B"
));
String
rosterReport
=
new
RosterReporter
(
session
).
getReport
();
System
.
out
.
println
(
rosterReport
);
assertEquals
(
RosterReporter
.
ROSTER_REPORT_HEADER
+
"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