Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AP-CHMIELEWSKI-Louis
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
Louis Chmielewski
AP-CHMIELEWSKI-Louis
Commits
9d43c1b7
Commit
9d43c1b7
authored
1 year ago
by
Louis Chmielewski
Browse files
Options
Downloads
Patches
Plain Diff
eq, neq, lt, le, gt, ge in card.py
parent
c4dc579c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Tp08/card.py
+26
-6
26 additions, 6 deletions
Tp08/card.py
Tp08/war.py
+3
-1
3 additions, 1 deletion
Tp08/war.py
with
29 additions
and
7 deletions
Tp08/card.py
+
26
−
6
View file @
9d43c1b7
...
...
@@ -148,42 +148,62 @@ class Card(object):
return True if self equals card
False otherwise
"""
...
return
(
self
.
value
==
card
.
value
)
and
(
self
.
color
==
card
.
color
)
def
__neq__
(
self
,
card
:
Card
)
->
bool
:
"""
return True if self don
'
t equal card
False otherwise
"""
...
return
(
self
.
value
!=
card
.
value
)
and
(
self
.
color
!=
card
.
color
)
def
__lt__
(
self
,
card
:
Card
)
->
bool
:
"""
return True if self is strictly inferior to card
False otherwise
"""
...
if
self
.
value
<
card
.
value
:
res
=
True
elif
self
.
value
==
card
.
value
:
if
self
.
color
<
card
.
color
:
res
=
True
else
:
res
=
False
else
:
res
=
False
return
res
def
__le__
(
self
,
card
:
Card
)
->
bool
:
"""
return True if self is inferior or equal to card
False otherwise
"""
...
return
self
.
value
<=
card
.
value
def
__gt__
(
self
,
card
:
Card
)
->
bool
:
"""
return True if self is strictly superior to card
False otherwise
"""
...
if
self
.
value
>
card
.
value
:
res
=
True
elif
self
.
value
==
card
.
value
:
if
self
.
color
>
card
.
color
:
res
=
True
else
:
res
=
False
else
:
res
=
False
return
res
def
__ge__
(
self
,
card
:
Card
)
->
bool
:
"""
return True if self is superior or equal to card
False otherwise
"""
...
return
self
.
value
>=
card
.
value
if
(
__name__
==
'
__main__
'
):
...
...
This diff is collapsed.
Click to expand it.
Tp08/war.py
+
3
−
1
View file @
9d43c1b7
...
...
@@ -62,7 +62,9 @@ def gather_stack(main: ApQueue, pile: ApStack) -> None:
$$$ all( main.dequeue() == cartes[ 3 - i ] for i in range(3))
True
"""
while
not
pile
.
is_empty
():
main
.
enqueue
(
pile
.
pop
())
return
main
def
play_one_round
(
m1
:
ApQueue
,
m2
:
ApQueue
,
pile
:
ApStack
)
->
None
:
"""
...
...
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