Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Lecture Demos
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Daniel Moix
Lecture Demos
Commits
f1ffc3d6
Commit
f1ffc3d6
authored
1 year ago
by
Daniel Moix
Browse files
Options
Downloads
Patches
Plain Diff
Added a working Clock class
parent
e78b9686
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
cs172/Lect03/WorkingClock.py
+39
-0
39 additions, 0 deletions
cs172/Lect03/WorkingClock.py
cs172/Lect03/old.py
+1
-1
1 addition, 1 deletion
cs172/Lect03/old.py
with
40 additions
and
1 deletion
cs172/Lect03/WorkingClock.py
0 → 100644
+
39
−
0
View file @
f1ffc3d6
class
Clock
:
def
__init__
(
self
):
self
.
__hours
=
12
self
.
__minutes
=
0
def
getHours
(
self
):
return
self
.
__hours
def
getMinutes
(
self
):
return
self
.
__minutes
def
getTime
(
self
):
return
f
"
{
self
.
__hours
}
:
{
str
(
self
.
__minutes
).
zfill
(
2
)
}
"
def
setTime
(
self
,
newHours
,
newMinutes
):
if
newHours
<=
12
and
newHours
>=
1
:
self
.
__hours
=
newHours
else
:
raise
Exception
(
"
Invalid value for hours
"
)
if
newMinutes
<=
59
and
newMinutes
>=
0
:
self
.
__minutes
=
newMinutes
else
:
raise
Exception
(
"
Invalid value for minutes
"
)
def
addMinute
(
self
):
self
.
__minutes
+=
1
if
self
.
__minutes
>
59
:
self
.
__minutes
=
0
self
.
__hours
+=
1
if
self
.
__hours
==
13
:
self
.
__hours
=
1
if
__name__
==
"
__main__
"
:
myClock
=
Clock
()
while
True
:
print
(
myClock
.
getTime
())
myClock
.
addMinute
()
This diff is collapsed.
Click to expand it.
cs172/Lect03/old.py
+
1
−
1
View file @
f1ffc3d6
def
main
():
def
main
():
print
(
"
This code is in the old file
"
)
print
(
"
This code is in the old file
"
)
s
def
printHappyFace
():
def
printHappyFace
():
print
(
"
😘
"
)
print
(
"
😘
"
)
...
...
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