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
fb332f27
authored
May 29, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SummerCourseSession created (Lesson 6 in progress)
parent
b1321304
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
94 additions
and
12 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/summer/SummerCourseSession.java
app/src/test/java/com/example/paktalin/agilejava/AllTests.java
app/src/test/java/com/example/paktalin/agilejava/LanguageTests.java → app/src/test/java/com/example/paktalin/agilejava/language_tests/LanguageTests.java
app/src/test/java/com/example/paktalin/agilejava/language_tests/SuperClassTest.java
app/src/test/java/com/example/paktalin/agilejava/summer/SummerCourseSessionTest.java
app/src/main/java/com/example/paktalin/agilejava/CourseSession.java
View file @
fb332f27
...
@@ -12,7 +12,7 @@ import java.util.List;
...
@@ -12,7 +12,7 @@ import java.util.List;
* Created by Paktalin on 16/05/2018.
* Created by Paktalin on 16/05/2018.
*/
*/
class
CourseSession
implements
Comparable
<
CourseSession
>{
public
class
CourseSession
implements
Comparable
<
CourseSession
>{
private
String
department
;
private
String
department
;
private
String
number
;
private
String
number
;
private
List
<
Student
>
students
=
new
ArrayList
<>();
private
List
<
Student
>
students
=
new
ArrayList
<>();
...
@@ -20,7 +20,7 @@ class CourseSession implements Comparable<CourseSession>{
...
@@ -20,7 +20,7 @@ class CourseSession implements Comparable<CourseSession>{
private
static
int
count
=
0
;
private
static
int
count
=
0
;
private
int
numberOfCredits
;
private
int
numberOfCredits
;
pr
ivate
CourseSession
(
String
department
,
String
number
,
Date
startDate
)
{
pr
otected
CourseSession
(
String
department
,
String
number
,
Date
startDate
)
{
this
.
department
=
department
;
this
.
department
=
department
;
this
.
number
=
number
;
this
.
number
=
number
;
this
.
startDate
=
startDate
;
this
.
startDate
=
startDate
;
...
@@ -55,22 +55,24 @@ class CourseSession implements Comparable<CourseSession>{
...
@@ -55,22 +55,24 @@ class CourseSession implements Comparable<CourseSession>{
return
students
.
size
();
return
students
.
size
();
}
}
Date
getEndDate
()
{
public
Date
getEndDate
()
{
GregorianCalendar
calendar
=
new
GregorianCalendar
();
GregorianCalendar
calendar
=
new
GregorianCalendar
();
calendar
.
setTime
(
startDate
);
calendar
.
setTime
(
getStartDate
()
);
calendar
.
add
(
Calendar
.
DAY_OF_YEAR
,
getNumberOfDays
());
calendar
.
add
(
Calendar
.
DAY_OF_YEAR
,
getNumberOfDays
InSession
());
return
calendar
.
getTime
();
return
calendar
.
getTime
();
}
}
Date
getStartDate
()
{
protected
Date
getStartDate
()
{
return
startDate
;
return
startDate
;
}
}
protected
int
getSessionLength
()
{
return
16
;
}
private
int
getNumberOfDays
()
{
protected
int
getNumberOfDaysInSession
()
{
final
int
sessionLength
=
16
;
final
int
daysInWeek
=
7
;
final
int
daysInWeek
=
7
;
final
int
daysFromFridayToMonday
=
3
;
final
int
daysFromFridayToMonday
=
3
;
return
sessionLength
*
daysInWeek
-
daysFromFridayToMonday
;
return
getSessionLength
()
*
daysInWeek
-
daysFromFridayToMonday
;
}
}
List
<
Student
>
getAllStudents
()
{
List
<
Student
>
getAllStudents
()
{
...
...
app/src/main/java/com/example/paktalin/agilejava/DateUtil.java
View file @
fb332f27
...
@@ -8,7 +8,7 @@ import java.util.GregorianCalendar;
...
@@ -8,7 +8,7 @@ import java.util.GregorianCalendar;
* Created by Paktalin on 17/05/2018.
* Created by Paktalin on 17/05/2018.
*/
*/
class
DateUtil
{
public
class
DateUtil
{
//That's how static initialization block works
//That's how static initialization block works
static
{
static
{
...
@@ -20,7 +20,7 @@ class DateUtil {
...
@@ -20,7 +20,7 @@ class DateUtil {
private
DateUtil
()
{}
private
DateUtil
()
{}
static
Date
createDate
(
int
year
,
int
month
,
int
date
)
{
public
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/summer/SummerCourseSession.java
0 → 100644
View file @
fb332f27
package
com
.
example
.
paktalin
.
agilejava
.
summer
;
import
com.example.paktalin.agilejava.CourseSession
;
import
java.util.Date
;
/**
* Created by Paktalin on 28/05/2018.
*/
public
class
SummerCourseSession
extends
CourseSession
{
static
SummerCourseSession
create
(
String
department
,
String
number
,
Date
startDate
)
{
return
new
SummerCourseSession
(
department
,
number
,
startDate
);
}
private
SummerCourseSession
(
String
department
,
String
number
,
Date
startDate
)
{
super
(
department
,
number
,
startDate
);
}
@Override
protected
int
getSessionLength
()
{
return
8
;
}
}
app/src/test/java/com/example/paktalin/agilejava/AllTests.java
View file @
fb332f27
package
com
.
example
.
paktalin
.
agilejava
;
package
com
.
example
.
paktalin
.
agilejava
;
import
com.example.paktalin.agilejava.language_tests.LanguageTests
;
import
com.example.paktalin.agilejava.language_tests.SuperClassTest
;
import
junit.framework.TestSuite
;
import
junit.framework.TestSuite
;
/**
/**
...
@@ -19,6 +22,7 @@ public class AllTests extends TestSuite {
...
@@ -19,6 +22,7 @@ public class AllTests extends TestSuite {
suite
.
addTestSuite
(
ReportCardTest
.
class
);
suite
.
addTestSuite
(
ReportCardTest
.
class
);
suite
.
addTestSuite
(
BasicGradingStrategyTest
.
class
);
suite
.
addTestSuite
(
BasicGradingStrategyTest
.
class
);
suite
.
addTestSuite
(
HonorsGradingStrategyTest
.
class
);
suite
.
addTestSuite
(
HonorsGradingStrategyTest
.
class
);
suite
.
addTestSuite
(
SuperClassTest
.
class
);
return
suite
;
return
suite
;
}
}
}
}
app/src/test/java/com/example/paktalin/agilejava/LanguageTests.java
→
app/src/test/java/com/example/paktalin/agilejava/
language_tests/
LanguageTests.java
View file @
fb332f27
package
com
.
example
.
paktalin
.
agilejava
;
package
com
.
example
.
paktalin
.
agilejava
.
language_tests
;
import
junit.framework.TestCase
;
import
junit.framework.TestCase
;
...
...
app/src/test/java/com/example/paktalin/agilejava/language_tests/SuperClassTest.java
0 → 100644
View file @
fb332f27
package
com
.
example
.
paktalin
.
agilejava
.
language_tests
;
import
junit.framework.TestCase
;
/**
* Created by Paktalin on 28/05/2018.
*/
public
class
SuperClassTest
extends
TestCase
{
public
void
testConstructorCalls
()
{
SuperClass
superClass
=
new
SubClass
(
"parm"
);
assertTrue
(
superClass
.
constructorWasCalled
);
}
class
SuperClass
{
boolean
constructorWasCalled
=
false
;
SuperClass
(
String
parm
)
{
constructorWasCalled
=
true
;
}
}
class
SubClass
extends
SuperClass
{
SubClass
(
String
parm
)
{
super
(
parm
);
}
}
}
app/src/test/java/com/example/paktalin/agilejava/summer/SummerCourseSessionTest.java
0 → 100644
View file @
fb332f27
package
com
.
example
.
paktalin
.
agilejava
.
summer
;
import
com.example.paktalin.agilejava.CourseSession
;
import
com.example.paktalin.agilejava.DateUtil
;
import
junit.framework.TestCase
;
import
java.util.Date
;
/**
* Created by Paktalin on 28/05/2018.
*/
public
class
SummerCourseSessionTest
extends
TestCase
{
public
void
testEndDate
()
{
Date
startDate
=
DateUtil
.
createDate
(
2003
,
6
,
9
);
CourseSession
session
=
SummerCourseSession
.
create
(
"ENGL"
,
"200"
,
startDate
);
Date
eightWeeksOut
=
DateUtil
.
createDate
(
2003
,
8
,
1
);
assertEquals
(
eightWeeksOut
,
session
.
getEndDate
());
}
}
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