Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kurs_alx_pcz
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
kurs_alx_pcz
Commits
98be1b10
Commit
98be1b10
authored
Dec 01, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dziedziczenie - start
parent
ba948686
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
klasy3.py
dzien7/klasy_wprowadzenie/klasy3.py
+47
-0
No files found.
dzien7/klasy_wprowadzenie/klasy3.py
0 → 100644
View file @
98be1b10
class
Osoba
:
def
__init__
(
self
,
imie
,
nazwisko
,
wiek
):
self
.
imie
=
imie
self
.
nazwisko
=
nazwisko
self
.
wiek
=
wiek
def
__str__
(
self
):
return
f
'{self.imie} {self.nazwisko} ({self.wiek} lat)'
def
przedstaw_sie
(
self
):
print
(
f
'Nazywam się {self.imie} {self.nazwisko} i mam {self.wiek} lat'
)
def
jest_pelnoletnia
(
self
):
return
self
.
wiek
>=
18
class
Student
(
Osoba
):
pass
class
Sklep
:
def
__init__
(
self
,
nazwa
):
self
.
nazwa
=
nazwa
self
.
cennik
=
{}
self
.
kasa
=
0
def
zdefiniuj_produkt
(
self
,
produkt
,
cena
):
self
.
cennik
[
produkt
]
=
cena
def
sprzedaj
(
self
,
produkt
,
klient
,
sztuk
=
1
):
if
produkt
not
in
self
.
cennik
:
print
(
f
'Nieznany produkt: {produkt}'
)
elif
produkt
in
{
'piwo'
}
and
not
klient
.
jest_pelnoletnia
():
print
(
f
'Osobom niepełnoletnim nie sprzedajemy {produkt}'
)
else
:
koszt
=
self
.
cennik
[
produkt
]
*
sztuk
print
(
f
'Kliencie {klient.imie}, za swoje zakupy płacisz {koszt}'
)
self
.
kasa
+=
koszt
osoba
=
Osoba
(
'Ala'
,
'Kowalska'
,
40
)
student
=
Student
(
'Bartek'
,
'Nowakowski'
,
20
)
print
(
'osoba:'
,
osoba
,
'typu'
,
type
(
osoba
))
print
(
'student:'
,
student
,
type
(
student
))
osoba
.
przedstaw_sie
()
student
.
przedstaw_sie
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment