Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dev-qu
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hugo Debuyser
dev-qu
Commits
26f11b0b
Commit
26f11b0b
authored
1 year ago
by
Hugo Debuyser
Browse files
Options
Downloads
Patches
Plain Diff
tpQU02::exo-WarriorCard
parent
7e0f4eb7
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/tpQU/tp02/WarriorCard.java
+118
-0
118 additions, 0 deletions
src/tpQU/tp02/WarriorCard.java
with
118 additions
and
0 deletions
src/tpQU/tp02/WarriorCard.java
0 → 100644
+
118
−
0
View file @
26f11b0b
package
tpQU.tp02
;
/**
* Classe permettant de créer une carte WarriorCard avec les différents attributs.
* @author Hugo D */
public
class
WarriorCard
{
//attributes
/**
* Attribut pour le nom de la carte. */
private
String
name
;
/**
* Attribut pour la valeur "force" de la carte. */
private
int
strength
;
/**
* Attribut pour la valeur "agilité" de la carte. */
private
int
agility
;
//constructor
/**
* Constructeur principale de la classe WarriorCard.
* @param name nom de la carte.
* @param s Attribut "froce" de la carte.
* @param ag Attribut "agilité" de la carte. */
public
WarriorCard
(
String
name
,
int
s
,
int
ag
){
this
.
name
=
name
;
this
.
strength
=
s
;
this
.
agility
=
ag
;
}
/**
* getteur pour l'attribut nom de la carte
* @return renvoie un String de l'attribut nom de la carte courante. */
public
String
getName
(){
return
this
.
name
;
}
/**
* getteur pour l'attribut "force" de la carte".
* @return renvoie un int de l'attribut "force" de la carte courante. */
public
int
getStrength
(){
return
this
.
strength
;
}
/**
* getteur pour l'attribut "agilité" de la carte.
* @return renvoie un int de l'attribut "agilité" de la carte courante. */
public
int
getAgility
(){
return
this
.
agility
;
}
/**
* setteur pout l'attribut nom de la carte.
* @param name Nouveau nom à attribuer à la carte courante. */
public
void
setNom
(
String
name
){
this
.
name
=
name
;
}
/**
* setteur pour l'attribut "strength" de la carte.
* @param strength Nouvelle valeur pour l'attribut "force" de la carte courante. */
public
void
setStrength
(
int
strength
){
this
.
strength
=
strength
;
}
/**
* setteur pout l'attribut "agility" de la carte.
* @param agility Nouvelle valeur pour l'attribut "agility" de la carte courante. */
public
void
setAgility
(
int
agility
){
this
.
agility
=
agility
;
}
/**
* Vérifie si un objet WarriorCard est égal à un autre.
* @param obj Autre carte passé en paramètre.
* @return renvoie True si les deux cartes sont identiques, sinon non. */
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
return
true
;
if
(
obj
==
null
||
getClass
()
!=
obj
.
getClass
())
return
false
;
WarriorCard
other
=
(
WarriorCard
)
obj
;
if
(
strength
!=
other
.
strength
)
return
false
;
if
(
agility
!=
other
.
agility
)
return
false
;
if
(
name
==
null
){
if
(
other
.
name
!=
null
)
return
false
;
}
else
if
(!
name
.
equals
(
other
.
name
))
return
false
;
return
true
;
}
/**
* Compare l'attribut "Force" de 2 cartes.
* @param other Autre carte passé en paramètre.
* @return renvoie -1 si la carte passé en paramètre à une valeur de "force" est supérieur à celle courante, 1 si inférieur et 0 si identique.*/
public
int
compareStrength
(
WarriorCard
other
){
if
(
this
.
strength
<
other
.
strength
)
return
-
1
;
if
(
this
.
strength
>
other
.
strength
)
return
1
;
return
0
;
}
/**
* Compare l'attribut "Agilité" de 2 cartes.
* @param other Autre carte passé en paramètre.
* @return renvoie -1 si la carte passé en paramètre à une valeur de "agilité" est supérieur à celle courante, 1 si inférieur et 0 si identique.*/
public
int
compareAgility
(
WarriorCard
other
){
if
(
this
.
agility
<
other
.
agility
)
return
-
1
;
if
(
this
.
agility
>
other
.
agility
)
return
1
;
return
0
;
}
/**
* renvoie la carte et ces valeur.
* @return renvoieee 'nom'[S='strength',A='agility'].*/
public
String
toString
(){
return
this
.
name
+
"[S="
+
this
.
strength
+
",A="
+
this
.
agility
+
"]"
;
}
}
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