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
068bbd1c
Commit
068bbd1c
authored
3 years ago
by
phenixceleste
Browse files
Options
Downloads
Patches
Plain Diff
TODO added, private mutable variable in pokemon
parent
e6081432
No related branches found
Branches containing commit
No related tags found
1 merge request
!6
Resolve "Upgrade Pokemon class"
Pipeline
#9680
passed with stage
in 2 minutes and 6 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/scala/Pokemon/Pokemon.scala
+15
-10
15 additions, 10 deletions
src/main/scala/Pokemon/Pokemon.scala
with
15 additions
and
10 deletions
src/main/scala/Pokemon/Pokemon.scala
+
15
−
10
View file @
068bbd1c
trait
Pokemon
(
// must add later max_life...
var
name
:
String
,
var
life
:
Int
,
trait
Pokemon
(
//
TODO:
must add later max_life...
private
var
_
name
:
String
,
private
var
_
life
:
Int
,
val
ptype
:
List
[
Type
],
var
pcapacity
:
List
[
Capacity
],
val
attack
:
Int
,
// val or var ?
val
defense
:
Int
,
// val or var ?
val
speed
:
Int
// val or var ?
_
pcapacity
:
List
[
Capacity
],
_
attack
:
Int
,
_
defense
:
Int
,
_
speed
:
Int
)
:
def
rename
(
newName:
String
)
=
this
.
name
=
newName
def
name:
String
=
this
.
_name
def
name_=
(
name
:
String
)
=
this
.
_name
=
name
def
attack
(
capacity
:
Capacity
,
other
:
Pokemon
)
=
val
multiplier
=
other
.
ptype
.
foldLeft
(
1.0
)(
_
*
capacity
.
ctype
.
typeEfficiency
(
_
).
factor
)
other
.
decreaseLife
(
Math
.
round
(
multiplier
.
toFloat
))
def
decreaseLife
(
x
:
Int
)
=
this
.
life
=
this
.
life
-
x
def
life
:
Int
=
this
.
_life
def
life_=
(
life
:
Int
)
=
this
.
_life
=
life
def
decreaseLife
(
x
:
Int
)
=
this
.
_life
=
this
.
_life
-
x
override
def
toString
()
:
String
=
s
"[${this.name}] Life: ${this.life}"
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