Skip to content
Snippets Groups Projects
Commit 6d989da7 authored by phenixceleste's avatar phenixceleste
Browse files

Verification of pokemon alive added

parent abd29ce0
No related branches found
No related tags found
1 merge request!13Resolve "Trainer class"
Pipeline #9733 passed with stage
in 1 minute and 50 seconds
......@@ -39,5 +39,7 @@ trait Pokemon(
def decreaseLife(x: Int): Unit = this._life = this.life - x
def isAlive: Boolean = !(this.life == 0)
override def toString(): String =
s"[${this.name}] Life: ${this.life}\nMaxLife: ${this.maxLife}\nAttack: ${this.attack}\nDefense: ${this.defense}\nSpeed: ${this.speed}\n"
......@@ -8,4 +8,5 @@ class Trainer(val name: String, var listPokemon: List[Pokemon], var indexPrimary
def changePrimaryPokemon(index: Int): Unit =
assert(0 <= index && index < this.numberPokemon)
assert(this.listPokemon(index).isAlive)
this.indexPrimaryPokemon = index
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment