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
635ac868
authored
May 27, 2018
by
Paktalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lesson 6 in progress
parent
983b8d32
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
90 additions
and
5 deletions
app/src/main/java/com/example/paktalin/agilejava/BasicGradingStrategy.java
app/src/main/java/com/example/paktalin/agilejava/ReportCard.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/ReportCardTest.java
app/src/main/java/com/example/paktalin/agilejava/BasicGradingStrategy.java
View file @
635ac868
...
...
@@ -7,10 +7,12 @@ package com.example.paktalin.agilejava;
class
BasicGradingStrategy
implements
GradingStrategy
{
@Override
public
int
getGradePointsFor
(
Student
.
Grade
grade
)
{
if
(
grade
==
Student
.
Grade
.
A
)
return
4
;
if
(
grade
==
Student
.
Grade
.
B
)
return
3
;
if
(
grade
==
Student
.
Grade
.
C
)
return
2
;
if
(
grade
==
Student
.
Grade
.
D
)
return
1
;
return
0
;
switch
(
grade
)
{
case
A:
return
4
;
case
B:
return
3
;
case
C:
return
2
;
case
D:
return
1
;
default
:
return
0
;
}
}
}
app/src/main/java/com/example/paktalin/agilejava/ReportCard.java
0 → 100644
View file @
635ac868
package
com
.
example
.
paktalin
.
agilejava
;
import
java.util.EnumMap
;
import
java.util.Map
;
/**
* Created by Paktalin on 27/05/2018.
*/
class
ReportCard
{
static
final
String
A_MESSAGE
=
"Excellent!"
;
static
final
String
B_MESSAGE
=
"Very good"
;
static
final
String
C_MESSAGE
=
"Hmmm..."
;
static
final
String
D_MESSAGE
=
"You're not trying"
;
static
final
String
F_MESSAGE
=
"Loser"
;
private
Map
<
Student
.
Grade
,
String
>
messages
=
null
;
public
String
getMessage
(
Student
.
Grade
grade
)
{
return
getMessages
().
get
(
grade
);
}
private
Map
<
Student
.
Grade
,
String
>
getMessages
()
{
if
(
messages
==
null
)
loadMessages
();
return
messages
;
}
private
void
loadMessages
()
{
messages
=
new
EnumMap
<>(
Student
.
Grade
.
class
);
messages
.
put
(
Student
.
Grade
.
A
,
A_MESSAGE
);
messages
.
put
(
Student
.
Grade
.
B
,
B_MESSAGE
);
messages
.
put
(
Student
.
Grade
.
C
,
C_MESSAGE
);
messages
.
put
(
Student
.
Grade
.
D
,
D_MESSAGE
);
messages
.
put
(
Student
.
Grade
.
F
,
F_MESSAGE
);
}
}
app/src/test/java/com/example/paktalin/agilejava/AllTests.java
View file @
635ac868
...
...
@@ -15,6 +15,8 @@ public class AllTests extends TestSuite {
suite
.
addTestSuite
(
RosterReporterTest
.
class
);
suite
.
addTestSuite
(
DateUtilTest
.
class
);
suite
.
addTestSuite
(
CourseReportTest
.
class
);
suite
.
addTestSuite
(
LanguageTests
.
class
);
suite
.
addTestSuite
(
ReportCardTest
.
class
);
return
suite
;
}
}
app/src/test/java/com/example/paktalin/agilejava/LanguageTests.java
View file @
635ac868
...
...
@@ -55,4 +55,30 @@ public class LanguageTests extends TestCase {
assertTrue
(
"B"
.
compareTo
(
"A"
)
>
0
);
}
enum
Score
{
fieldGoal
,
touchdown
,
extraPoint
,
twoPointConversion
,
safety
}
public
void
testSwitchResults
()
{
int
totalPoints
=
0
;
Score
score
=
Score
.
touchdown
;
switch
(
score
)
{
case
fieldGoal:
totalPoints
+=
3
;
break
;
case
touchdown:
totalPoints
+=
6
;
break
;
case
extraPoint:
totalPoints
+=
1
;
break
;
case
twoPointConversion:
case
safety:
totalPoints
+=
2
;
break
;
}
assertEquals
(
6
,
totalPoints
);
}
}
app/src/test/java/com/example/paktalin/agilejava/ReportCardTest.java
0 → 100644
View file @
635ac868
package
com
.
example
.
paktalin
.
agilejava
;
import
junit.framework.TestCase
;
/**
* Created by Paktalin on 27/05/2018.
*/
public
class
ReportCardTest
extends
TestCase
{
public
void
testMessage
()
{
ReportCard
card
=
new
ReportCard
();
assertEquals
(
ReportCard
.
A_MESSAGE
,
card
.
getMessage
(
Student
.
Grade
.
A
));
assertEquals
(
ReportCard
.
B_MESSAGE
,
card
.
getMessage
(
Student
.
Grade
.
B
));
assertEquals
(
ReportCard
.
C_MESSAGE
,
card
.
getMessage
(
Student
.
Grade
.
C
));
assertEquals
(
ReportCard
.
D_MESSAGE
,
card
.
getMessage
(
Student
.
Grade
.
D
));
assertEquals
(
ReportCard
.
F_MESSAGE
,
card
.
getMessage
(
Student
.
Grade
.
F
));
}
}
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