Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ap-belfadel-mohamed
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
Mohamed Belfadel
ap-belfadel-mohamed
Commits
24c713fb
Commit
24c713fb
authored
1 year ago
by
Belfadel Mohamed
Browse files
Options
Downloads
Patches
Plain Diff
repr
parent
b88fe4de
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
TP9/card.py
+14
-6
14 additions, 6 deletions
TP9/card.py
with
14 additions
and
6 deletions
TP9/card.py
100644 → 100755
+
14
−
6
View file @
24c713fb
...
@@ -53,7 +53,8 @@ class Card(object):
...
@@ -53,7 +53,8 @@ class Card(object):
précondition : value in VALUES and color in COLORS
précondition : value in VALUES and color in COLORS
"""
"""
...
self
.
value
=
value
self
.
color
=
color
def
__hash__
(
self
)
->
int
:
def
__hash__
(
self
)
->
int
:
...
@@ -66,11 +67,11 @@ class Card(object):
...
@@ -66,11 +67,11 @@ class Card(object):
"""
"""
return a string representation of the card
return a string representation of the card
$$$ Card(
'
Ace
'
,
'
heart
'
)
$$$
repr(
Card(
'
Ace
'
,
'
heart
'
)
)
Card(
"
Ace
"
,
"
heart
"
)
'
Card(
"
Ace
"
,
"
heart
"
)
'
"""
"""
...
return
f
"
Card(
\"
{
self
.
value
}
\"
,
\"
{
self
.
color
}
\"
)
"
def
compare
(
self
,
card
:
Card
)
->
int
:
def
compare
(
self
,
card
:
Card
)
->
int
:
"""
"""
compares cards.
compares cards.
...
@@ -97,7 +98,14 @@ class Card(object):
...
@@ -97,7 +98,14 @@ class Card(object):
$$$ c1.compare(c3) == 0
$$$ c1.compare(c3) == 0
True
True
"""
"""
...
if
Card
.
VALUES
.
index
(
self
.
value
)
>
Card
.
VALUES
.
index
(
card
.
value
):
res
=
1
elif
Card
.
VALUES
.
index
(
self
.
value
)
<
Card
.
VALUES
.
index
(
card
.
value
):
res
=
-
1
else
:
res
=
0
return
res
@staticmethod
@staticmethod
def
deck
(
n_card
:
int
)
->
list
[
Card
]:
def
deck
(
n_card
:
int
)
->
list
[
Card
]:
...
...
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