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
0f8d14f1
authored
May 17, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Page 116. Lesson 3 is not completed yet
parent
f73a23d5
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
140 additions
and
18 deletions
app/src/main/java/com/example/paktalin/agilejava/CourseSession.java
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/AllTests.java
app/src/test/java/com/example/paktalin/agilejava/CourseSessionTest.java
app/src/test/java/com/example/paktalin/agilejava/DateUtilTest.java
app/src/test/java/com/example/paktalin/agilejava/LanguageTests.java
app/src/test/java/com/example/paktalin/agilejava/RosterReporterTest.java
app/src/main/java/com/example/paktalin/agilejava/CourseSession.java
View file @
0f8d14f1
...
@@ -15,11 +15,6 @@ class CourseSession {
...
@@ -15,11 +15,6 @@ class CourseSession {
private
ArrayList
<
Student
>
students
=
new
ArrayList
<>();
private
ArrayList
<
Student
>
students
=
new
ArrayList
<>();
private
Date
startDate
;
private
Date
startDate
;
CourseSession
(
String
department
,
String
number
)
{
this
.
department
=
department
;
this
.
number
=
number
;
}
CourseSession
(
String
department
,
String
number
,
Date
startDate
)
{
CourseSession
(
String
department
,
String
number
,
Date
startDate
)
{
this
.
department
=
department
;
this
.
department
=
department
;
this
.
number
=
number
;
this
.
number
=
number
;
...
@@ -63,4 +58,8 @@ class CourseSession {
...
@@ -63,4 +58,8 @@ class CourseSession {
final
int
daysFromFridayToMonday
=
3
;
final
int
daysFromFridayToMonday
=
3
;
return
sessionLength
*
daysInWeek
-
daysFromFridayToMonday
;
return
sessionLength
*
daysInWeek
-
daysFromFridayToMonday
;
}
}
ArrayList
<
Student
>
getAllStudents
()
{
return
students
;
}
}
}
app/src/main/java/com/example/paktalin/agilejava/DateUtil.java
0 → 100644
View file @
0f8d14f1
package
com
.
example
.
paktalin
.
agilejava
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.GregorianCalendar
;
/**
* Created by Paktalin on 17/05/2018.
*/
class
DateUtil
{
Date
createDate
(
int
year
,
int
month
,
int
date
)
{
GregorianCalendar
calendar
=
new
GregorianCalendar
();
calendar
.
clear
();
calendar
.
set
(
Calendar
.
YEAR
,
year
);
calendar
.
set
(
Calendar
.
MONTH
,
month
-
1
);
calendar
.
set
(
Calendar
.
DAY_OF_MONTH
,
date
);
return
calendar
.
getTime
();
}
}
app/src/main/java/com/example/paktalin/agilejava/RosterReporter.java
0 → 100644
View file @
0f8d14f1
package
com
.
example
.
paktalin
.
agilejava
;
/**
* Created by Paktalin on 17/05/2018.
*/
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_FOOTER
=
NEW_LINE
+
"# students = "
;
private
CourseSession
session
;
RosterReporter
(
CourseSession
session
)
{
this
.
session
=
session
;
}
String
getReport
()
{
StringBuilder
buffer
=
new
StringBuilder
();
buffer
.
append
(
ROSTER_REPORT_HEADER
);
for
(
Student
student
:
session
.
getAllStudents
())
{
buffer
.
append
(
student
.
getName
());
buffer
.
append
(
NEW_LINE
);
}
buffer
.
append
(
ROSTER_REPORT_FOOTER
+
session
.
getAllStudents
().
size
()
+
NEW_LINE
);
return
buffer
.
toString
();
}
}
app/src/test/java/com/example/paktalin/agilejava/AllTests.java
View file @
0f8d14f1
...
@@ -12,6 +12,8 @@ public class AllTests extends TestSuite {
...
@@ -12,6 +12,8 @@ public class AllTests extends TestSuite {
TestSuite
suite
=
new
TestSuite
();
TestSuite
suite
=
new
TestSuite
();
suite
.
addTestSuite
(
StudentTest
.
class
);
suite
.
addTestSuite
(
StudentTest
.
class
);
suite
.
addTestSuite
(
CourseSessionTest
.
class
);
suite
.
addTestSuite
(
CourseSessionTest
.
class
);
suite
.
addTestSuite
(
RosterReporterTest
.
class
);
suite
.
addTestSuite
(
DateUtilTest
.
class
);
return
suite
;
return
suite
;
}
}
}
}
app/src/test/java/com/example/paktalin/agilejava/CourseSessionTest.java
View file @
0f8d14f1
...
@@ -2,9 +2,7 @@ package com.example.paktalin.agilejava;
...
@@ -2,9 +2,7 @@ package com.example.paktalin.agilejava;
import
junit.framework.TestCase
;
import
junit.framework.TestCase
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.GregorianCalendar
;
/**
/**
* Created by Paktalin on 16/05/2018.
* Created by Paktalin on 16/05/2018.
...
@@ -16,7 +14,7 @@ public class CourseSessionTest extends TestCase {
...
@@ -16,7 +14,7 @@ public class CourseSessionTest extends TestCase {
private
Date
startDate
;
private
Date
startDate
;
public
void
setUp
()
{
public
void
setUp
()
{
startDate
=
createDate
(
2003
,
1
,
6
);
startDate
=
new
DateUtil
().
createDate
(
2003
,
1
,
6
);
session
=
new
CourseSession
(
"ENGL"
,
"101"
,
startDate
);
session
=
new
CourseSession
(
"ENGL"
,
"101"
,
startDate
);
}
}
...
@@ -40,16 +38,7 @@ public class CourseSessionTest extends TestCase {
...
@@ -40,16 +38,7 @@ public class CourseSessionTest extends TestCase {
}
}
public
void
testCourseDates
()
{
public
void
testCourseDates
()
{
Date
sixteenWeeksOut
=
createDate
(
2003
,
4
,
25
);
Date
sixteenWeeksOut
=
new
DateUtil
().
createDate
(
2003
,
4
,
25
);
assertEquals
(
sixteenWeeksOut
,
session
.
getEndDate
());
assertEquals
(
sixteenWeeksOut
,
session
.
getEndDate
());
}
}
private
Date
createDate
(
int
year
,
int
month
,
int
date
)
{
GregorianCalendar
calendar
=
new
GregorianCalendar
();
calendar
.
clear
();
calendar
.
set
(
Calendar
.
YEAR
,
year
);
calendar
.
set
(
Calendar
.
MONTH
,
month
-
1
);
calendar
.
set
(
Calendar
.
DAY_OF_MONTH
,
date
);
return
calendar
.
getTime
();
}
}
}
app/src/test/java/com/example/paktalin/agilejava/DateUtilTest.java
0 → 100644
View file @
0f8d14f1
package
com
.
example
.
paktalin
.
agilejava
;
import
junit.framework.TestCase
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.GregorianCalendar
;
/**
* Created by Paktalin on 17/05/2018.
*/
public
class
DateUtilTest
extends
TestCase
{
public
void
testCreateDate
()
{
Date
date
=
new
DateUtil
().
createDate
(
2000
,
1
,
1
);
Calendar
calendar
=
new
GregorianCalendar
();
calendar
.
setTime
(
date
);
assertEquals
(
2000
,
calendar
.
get
(
Calendar
.
YEAR
));
assertEquals
(
Calendar
.
JANUARY
,
calendar
.
get
(
Calendar
.
MONTH
));
assertEquals
(
1
,
calendar
.
get
(
Calendar
.
DAY_OF_MONTH
));
}
}
app/src/test/java/com/example/paktalin/agilejava/LanguageTests.java
0 → 100644
View file @
0f8d14f1
package
com
.
example
.
paktalin
.
agilejava
;
import
junit.framework.TestCase
;
/**
* Created by Paktalin on 17/05/2018.
*/
public
class
LanguageTests
extends
TestCase
{
public
void
testCharValue
()
{
char
capitalA
=
'A'
;
assertEquals
(
65
,
capitalA
);
assertEquals
(
'\u0041'
,
capitalA
);
assertEquals
(
'\
101
'
,
capitalA
);
}
public
void
testConcatenation
()
{
assertEquals
(
"abcd"
,
"ab"
.
concat
(
"cd"
));
assertEquals
(
"abcd"
,
"ab"
+
"cd"
);
assertEquals
(
"abcd"
,
"ab"
+
"c"
+
"d"
);
}
}
app/src/test/java/com/example/paktalin/agilejava/RosterReporterTest.java
0 → 100644
View file @
0f8d14f1
package
com
.
example
.
paktalin
.
agilejava
;
import
junit.framework.TestCase
;
/**
* Created by Paktalin on 17/05/2018.
*/
public
class
RosterReporterTest
extends
TestCase
{
public
void
testRosterReport
()
{
CourseSession
session
=
new
CourseSession
(
"ENGL"
,
"101"
,
new
DateUtil
().
createDate
(
2003
,
1
,
6
));
session
.
enroll
(
new
Student
(
"A"
));
session
.
enroll
(
new
Student
(
"B"
));
String
rosterReport
=
new
RosterReporter
(
session
).
getReport
();
assertEquals
(
RosterReporter
.
ROSTER_REPORT_HEADER
+
"A"
+
RosterReporter
.
NEW_LINE
+
"B"
+
RosterReporter
.
NEW_LINE
+
RosterReporter
.
ROSTER_REPORT_FOOTER
+
"2"
+
RosterReporter
.
NEW_LINE
,
rosterReport
);
}
}
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