Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dev-oo
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Samuel Turpin
dev-oo
Commits
0148e055
Commit
0148e055
authored
1 year ago
by
Samuel Turpin
Browse files
Options
Downloads
Patches
Plain Diff
tp3 of QD
parent
686b003b
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/projetjeu/Calculatrice.java
+2
-1
2 additions, 1 deletion
src/projetjeu/Calculatrice.java
src/projetjeu/devinelenombre/DevineNombre.java
+17
-0
17 additions, 0 deletions
src/projetjeu/devinelenombre/DevineNombre.java
src/tp03/Card.java
+58
-15
58 additions, 15 deletions
src/tp03/Card.java
with
77 additions
and
16 deletions
src/
td05
/Calculatrice.java
→
src/
projetjeu
/Calculatrice.java
+
2
−
1
View file @
0148e055
package
td05
;
package
projetjeu
;
import
java.util.Scanner
;
...
...
@@ -23,6 +23,7 @@ public class Calculatrice
}
return
true
;
}
@SuppressWarnings
(
"resource"
)
public
static
void
main
(
String
[]
args
)
{
Scanner
sc
=
new
Scanner
(
System
.
in
);
...
...
This diff is collapsed.
Click to expand it.
src/projetjeu/devinelenombre/DevineNombre.java
0 → 100644
+
17
−
0
View file @
0148e055
package
projetjeu.devinelenombre
;
public
class
DevineNombre
{
private
static
void
m
(
String
m
)
{
System
.
out
.
println
(
m
);
}
public
static
void
main
(
String
[]
args
)
{
m
(
"Jouons à un jeu..."
);
m
(
"Je vais penser à un nombre..."
);
m
(
"Et toi tu devras le retrouver..."
);
m
(
"Tu dispose de 5 tentatives..."
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/tp03/Card.java
+
58
−
15
View file @
0148e055
package
tp03
;
/**
* Cette classe créer une carte en spécifiant sa couleur et sont rang
*
* @author Samuel Turpin
*/
public
class
Card
{
/* Déclaration privée de la couleur et le rang de la carte */
private
Color
c
;
private
Rank
r
;
/*
*
* Constructeur principal
*
*/
public
Card
(
Color
color
,
Rank
rank
)
{
this
.
c
=
color
;
this
.
r
=
rank
;
}
/* Autre constructeur (NON FINI) */
public
Card
(
String
color
,
String
rank
)
{
System
.
out
.
println
(
"Constructeur en chantier"
+
color
+
rank
);
}
/* Accesseur pour la variable color */
public
Color
getColor
()
{
return
this
.
c
;
}
/* Accesseur pour la variable rank */
public
Rank
getRank
()
{
return
this
.
r
;
}
/* Comparateur de Rang
* - renvoie 0 si c'est le même objet ou qu'il à le même rang
* - renvoie -1 si l'ordre de l'objet enum est inférieur
* - renvoie 1 si l'ordre de l'objet enum est supérieur
* - renvoie 2 si aucune condition n'a marché
*/
public
int
compareRank
(
Card
c
)
{
if
(
this
==
c
)
{
return
0
;
}
if
(
c
.
r
==
this
.
r
)
{
return
0
;
}
if
(
this
.
r
.
ordinal
()
<
c
.
r
.
ordinal
())
{
return
-
1
;
}
if
(
this
.
r
.
ordinal
()
>
c
.
r
.
ordinal
())
{
return
1
;
}
return
2
;
int
retour
=
2
;
if
(
this
==
c
||
c
.
r
==
this
.
r
)
{
retour
=
0
;
}
if
(
this
.
r
.
ordinal
()
<
c
.
r
.
ordinal
())
{
retour
=
-
1
;
}
if
(
this
.
r
.
ordinal
()
>
c
.
r
.
ordinal
())
{
retour
=
1
;
}
return
retour
;
}
/* Comparateur de Couleur
* - renvoie 0 si c'est le même objet ou qu'il à le même couleur
* - renvoie -1 si l'ordre de l'objet enum est inférieur
* - renvoie 1 si l'ordre de l'objet enum est supérieur
* - renvoie 2 si aucune condition n'a marché
*/
public
int
compareColor
(
Card
c
)
{
if
(
this
==
c
)
{
return
0
;
}
if
(
c
.
c
==
this
.
c
)
{
return
0
;
}
if
(
this
.
c
.
ordinal
()
<
c
.
c
.
ordinal
())
{
return
-
1
;
}
if
(
this
.
c
.
ordinal
()
>
c
.
c
.
ordinal
())
{
return
1
;
}
return
2
;
int
retour
=
2
;
if
(
this
.
equals
(
c
))
{
retour
=
0
;
}
if
(
this
.
c
.
ordinal
()
<
c
.
c
.
ordinal
())
{
retour
=
-
1
;
}
if
(
this
.
c
.
ordinal
()
>
c
.
c
.
ordinal
())
{
retour
=
1
;
}
return
retour
;
}
/* Méthode retournant true tout le temps (probablement non fini) */
public
boolean
isBefore
(
Card
c
)
{
return
true
;
}
/* Méthode boolean d'égalité entre deux cartes */
public
boolean
equals
(
Card
c
)
{
if
(
this
==
c
)
{
return
true
;
}
if
(
c
==
null
)
{
return
false
;
}
if
(
c
.
c
==
this
.
c
&&
c
.
r
==
this
.
r
)
{
return
true
;
}
if
(
this
==
c
)
{
return
true
;
}
if
(
this
.
c
==
c
.
c
&&
this
.
r
==
c
.
r
)
{
return
true
;
}
return
false
;
}
/* Méthode toString() sans intérer */
@Override
public
String
toString
()
{
return
"mc"
;
...
...
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