Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
L3 - Projet programmation 2
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
v-lafeychine
L3 - Projet programmation 2
Commits
45d7d180
Commit
45d7d180
authored
3 years ago
by
phenixceleste
Browse files
Options
Downloads
Patches
Plain Diff
test changed as ask in discussion ; type Basic efficiency renamed in Neutral
parent
82b9cec5
No related branches found
Branches containing commit
No related tags found
1 merge request
!5
Resolve "Type class"
Pipeline
#9674
failed with stage
in 2 minutes and 19 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/main/scala/Pokemon/Efficiency.scala
+1
-1
1 addition, 1 deletion
src/main/scala/Pokemon/Efficiency.scala
src/main/scala/Pokemon/Type.scala
+1
-1
1 addition, 1 deletion
src/main/scala/Pokemon/Type.scala
src/test/scala/Test.scala
+8
-8
8 additions, 8 deletions
src/test/scala/Test.scala
with
10 additions
and
10 deletions
src/main/scala/Pokemon/Efficiency.scala
+
1
−
1
View file @
45d7d180
class
Efficiency
(
val
factor
:
Double
)
case
object
Efficient
extends
Efficiency
(
2.0
)
case
object
Basic
extends
Efficiency
(
1.0
)
case
object
Neutral
extends
Efficiency
(
1.0
)
case
object
NotEfficient
extends
Efficiency
(
0.5
)
case
object
Inefficient
extends
Efficiency
(
0.0
)
This diff is collapsed.
Click to expand it.
src/main/scala/Pokemon/Type.scala
+
1
−
1
View file @
45d7d180
...
...
@@ -3,7 +3,7 @@ sealed trait Type(val strong_on: List[Type], val weak_on: List[Type], val ineffi
if
strong_on
.
contains
(
ptype
)
then
Efficient
else
if
weak_on
.
contains
(
ptype
)
then
NotEfficient
else
if
inefficient_on
.
contains
(
ptype
)
then
Inefficient
else
Basic
else
Neutral
case
object
Normal
extends
Type
(
List
(),
List
(
Rock
),
List
(
Ghost
))
case
object
Fight
extends
Type
(
List
(
Normal
,
Rock
,
Ice
),
List
(
Poison
,
Flying
,
Bug
,
Psychic
),
List
(
Ghost
))
...
...
This diff is collapsed.
Click to expand it.
src/test/scala/Test.scala
+
8
−
8
View file @
45d7d180
...
...
@@ -3,18 +3,18 @@ import org.scalatest.funsuite.AnyFunSuite
class
StackSpec
extends
AnyFunSuite
:
test
(
"
Strong
type
should
have
increased
damage
multiplicator
"
)
{
assert
(
Fire.
type
Efficiency
(
Grass
)
.factor
==
2
.
0
)
test
(
"
Strong
type
should
be
efficient
"
)
{
assert
(
Fire.
type
Efficiency
(
Grass
)
==
Efficient
)
}
test
(
"Weak type should
have decreased damage multiplicator
"
)
{
assert
(
Bug
.
typeEfficiency
(
Fight
).
factor
==
0.5
)
test
(
"Weak type should
n't be efficient
"
)
{
assert
(
Bug
.
typeEfficiency
(
Fight
).
factor
==
NotEfficient
)
}
test
(
"
Common
type should
hav
e neutral
damage multiplicator
"
)
{
assert
(
Electric
.
typeEfficiency
(
Poison
)
.
factor
==
1.0
)
test
(
"
Normal
type should
b
e neutral"
)
{
assert
(
Electric
.
typeEfficiency
(
Poison
)
==
Neutral
)
}
test
(
"Inefficient type should
have null damage multiplicator
"
)
{
assert
(
Normal
.
typeEfficiency
(
Ghost
)
.
factor
==
0.0
)
test
(
"Inefficient type should
be inefficient
"
)
{
assert
(
Normal
.
typeEfficiency
(
Ghost
)
==
Inefficient
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment