Author Dusty Phillips Reviewers


PropertyClass = self.type_map[



Download 2,95 Mb.
Pdf ko'rish
bet97/183
Sana20.07.2022
Hajmi2,95 Mb.
#831085
1   ...   93   94   95   96   97   98   99   100   ...   183
Bog'liq
python3-oop

PropertyClass = self.type_map[
(property_type, payment_type)]
init_args = PropertyClass.prompt_init()
self.property_list.append(PropertyClass(**init_args))
This may look a bit funny too! We look up the class in the dictionary and store it in 
a variable named 
PropertyClass
. We don't know exactly which class is available, 
but the class knows itself, so we can polymorphically call 
prompt_init
to get a 
dictionary of values appropriate to pass into the constructor. Then we use the 
keyword argument syntax to convert the dictionary into arguments and construct 
the new object to load the correct data.
Now our user can use this 
Agent
class to add and view lists of properties. It wouldn't 
take much work to add features to mark a property as available or unavailable or
to edit and remove properties. Our prototype is now in a good enough state to take 
to a real estate 
agent
and demonstrate its functionality. Here's how a demo session 
might work:
>>> agent = Agent()
>>> agent.add_property()
What type of property? (house, apartment) house
What payment type? (purchase, rental) rental
Enter the square feet: 900
Enter number of bedrooms: 2
Enter number of baths: one and a half
www.it-ebooks.info


When Objects Are Alike
[
 94 
]
Is the yard fenced? (yes, no) yes
Is there a garage? (attached, detached, none) detached
How many stories? 1
What is the monthly rent? 1200
What are the estimated utilities? included
Is the property furnished? (yes, no) no
>>> agent.add_property()
What type of property? (house, apartment) apartment

Download 2,95 Mb.

Do'stlaringiz bilan baham:
1   ...   93   94   95   96   97   98   99   100   ...   183




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish