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
f73a23d5
authored
May 17, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lesson 2 is done
parent
8d5faa1a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
140 additions
and
22 deletions
app/src/main/AndroidManifest.xml
app/src/main/java/com/example/paktalin/agilejava/CourseSession.java
app/src/main/java/com/example/paktalin/agilejava/MainActivity.java
app/src/test/java/com/example/paktalin/agilejava/AllTests.java
app/src/test/java/com/example/paktalin/agilejava/CourseSessionTest.java
app/src/main/AndroidManifest.xml
View file @
f73a23d5
...
...
@@ -8,14 +8,6 @@
android:label=
"@string/app_name"
android:roundIcon=
"@mipmap/ic_launcher_round"
android:supportsRtl=
"true"
android:theme=
"@style/AppTheme"
>
<activity
android:name=
".MainActivity"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
</application>
android:theme=
"@style/AppTheme"
></application>
</manifest>
\ No newline at end of file
app/src/main/java/com/example/paktalin/agilejava/CourseSession.java
0 → 100644
View file @
f73a23d5
package
com
.
example
.
paktalin
.
agilejava
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.GregorianCalendar
;
/**
* Created by Paktalin on 16/05/2018.
*/
class
CourseSession
{
private
String
department
;
private
String
number
;
private
ArrayList
<
Student
>
students
=
new
ArrayList
<>();
private
Date
startDate
;
CourseSession
(
String
department
,
String
number
)
{
this
.
department
=
department
;
this
.
number
=
number
;
}
CourseSession
(
String
department
,
String
number
,
Date
startDate
)
{
this
.
department
=
department
;
this
.
number
=
number
;
this
.
startDate
=
startDate
;
}
String
getDepartment
()
{
return
department
;
}
String
getNumber
()
{
return
number
;
}
void
enroll
(
Student
student
)
{
students
.
add
(
student
);
}
Student
get
(
int
index
)
{
return
students
.
get
(
index
);
}
int
getNumberOfStudents
()
{
return
students
.
size
();
}
Date
getEndDate
()
{
GregorianCalendar
calendar
=
new
GregorianCalendar
();
calendar
.
setTime
(
startDate
);
calendar
.
add
(
Calendar
.
DAY_OF_YEAR
,
getNumberOfDays
());
return
calendar
.
getTime
();
}
Date
getStartDate
()
{
return
startDate
;
}
private
int
getNumberOfDays
()
{
final
int
sessionLength
=
16
;
final
int
daysInWeek
=
7
;
final
int
daysFromFridayToMonday
=
3
;
return
sessionLength
*
daysInWeek
-
daysFromFridayToMonday
;
}
}
app/src/main/java/com/example/paktalin/agilejava/MainActivity.java
deleted
100644 → 0
View file @
8d5faa1a
package
com
.
example
.
paktalin
.
agilejava
;
import
android.support.v7.app.AppCompatActivity
;
import
android.os.Bundle
;
public
class
MainActivity
extends
AppCompatActivity
{
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
}
}
app/src/test/java/com/example/paktalin/agilejava/AllTests.java
0 → 100644
View file @
f73a23d5
package
com
.
example
.
paktalin
.
agilejava
;
import
junit.framework.TestSuite
;
/**
* Created by Paktalin on 16/05/2018.
*/
public
class
AllTests
extends
TestSuite
{
public
static
TestSuite
suite
()
{
TestSuite
suite
=
new
TestSuite
();
suite
.
addTestSuite
(
StudentTest
.
class
);
suite
.
addTestSuite
(
CourseSessionTest
.
class
);
return
suite
;
}
}
app/src/test/java/com/example/paktalin/agilejava/CourseSessionTest.java
0 → 100644
View file @
f73a23d5
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 16/05/2018.
*/
public
class
CourseSessionTest
extends
TestCase
{
private
CourseSession
session
;
private
Date
startDate
;
public
void
setUp
()
{
startDate
=
createDate
(
2003
,
1
,
6
);
session
=
new
CourseSession
(
"ENGL"
,
"101"
,
startDate
);
}
public
void
testCreate
()
{
assertEquals
(
"ENGL"
,
session
.
getDepartment
());
assertEquals
(
"101"
,
session
.
getNumber
());
assertEquals
(
0
,
session
.
getNumberOfStudents
());
assertEquals
(
startDate
,
session
.
getStartDate
());
}
public
void
testEnrollStudents
()
{
Student
student1
=
new
Student
(
"Cain DiVoe"
);
session
.
enroll
(
student1
);
assertEquals
(
student1
,
session
.
get
(
0
));
assertEquals
(
1
,
session
.
getNumberOfStudents
());
Student
student2
=
new
Student
(
"Coralee DeVaughn"
);
session
.
enroll
(
student2
);
assertEquals
(
student2
,
session
.
get
(
1
));
assertEquals
(
2
,
session
.
getNumberOfStudents
());
}
public
void
testCourseDates
()
{
Date
sixteenWeeksOut
=
createDate
(
2003
,
4
,
25
);
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
();
}
}
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