Author Dusty Phillips Reviewers



Download 2,95 Mb.
Pdf ko'rish
bet89/183
Sana20.07.2022
Hajmi2,95 Mb.
#831085
1   ...   85   86   87   88   89   90   91   92   ...   183
Bog'liq
python3-oop

[
 83 
]
The project will allow the agent to interact with the objects using the Python interpreter 
prompt. In this world of graphical user interfaces and web applications, you might 
be wondering why we're creating such old-fashioned looking programs. Simply put, 
both windowed programs and web applications require a lot of overhead knowledge 
and boilerplate code to make them do what is required. If we were developing 
software using either of these paradigms, we'd get so lost in GUI programming or web 
programming that we'd lose sight of the object-oriented principles we're trying
to master.
Luckily, most GUI and web frameworks utilize an object-oriented approach, and 
the principles we're studying now will help in understanding those systems in the 
future. We'll discuss them both briefly in 
Chapter 13

Concurrency
, but complete 
details are far beyond the scope of a single book.
Looking at our requirements, it seems like there are quite a few nouns that might 
represent classes of objects in our system. Clearly, we'll need to represent a property. 
Houses and apartments may need separate classes. Rentals and purchases also seem 
to require separate representation. Since we're focusing on inheritance right now, 
we'll be looking at ways to share behavior using inheritance or multiple inheritance.
House
and 
Apartment
are both types of properties, so 
Property
can be a superclass 
of those two classes. 
Rental
and 
Purchase
will need some extra thought; if we use 
inheritance, we'll need to have separate classes, for example, for 
HouseRental
and 
HousePurchase
, and use multiple inheritance to combine them. This feels a little 
clunky compared to a composition or association-based design, but let's run with
it and see what we come up with.
Now then, what attributes might be associated with a 
Property
class? Regardless 
of whether it is an apartment or a house, most people will want to know the square 
footage, number of bedrooms, and number of bathrooms. (There are numerous
other attributes that might be modeled, but we'll keep it simple for our prototype.)
If the property is a house, it will want to advertise the number of stories, whether 
it has a garage (attached, detached, or none), and whether the yard is fenced. An 
apartment will want to indicate if it has a balcony, and if the laundry is ensuite,
coin, or off-site.
Both property types will require a method to display the characteristics of that 
property. At the moment, no other behaviors are apparent.
Rental properties will need to store the rent per month, whether the property is 
furnished, and whether utilities are included, and if not, what they are estimated to 
be. Properties for purchase will need to store the purchase price and estimated annual 
property taxes. For our application, we'll only need to display this data, so we can get 
away with just adding a 
display()
method similar to that used in the other classes.
www.it-ebooks.info


When Objects Are Alike

Download 2,95 Mb.

Do'stlaringiz bilan baham:
1   ...   85   86   87   88   89   90   91   92   ...   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