Author Dusty Phillips Reviewers



Download 2,95 Mb.
Pdf ko'rish
bet16/183
Sana20.07.2022
Hajmi2,95 Mb.
#831085
1   ...   12   13   14   15   16   17   18   19   ...   183
Bog'liq
python3-oop

+Weight
+Orchard
+Date_Picked
Orange
+location
Basket
+Color
+Weight
Apple
+size
Barrel
go in
go in
*
1
*
1
In our fruit inventory application, the fruit farmer may want to know what orchard 
the orange came from, when it was picked, and how much it weighs. They might 
also want to keep track of where each basket is stored. Apples might have a color 
attribute, and barrels might come in different sizes. Some of these properties may 
also belong to multiple classes (we may want to know when apples are picked, too), 
but for this first example, let's just add a few different attributes to our class diagram:
www.it-ebooks.info


Chapter 1
[
 7 
]
Orange
Basket
Apple
Barrel
go in
go in
*
1
*
1
+Color: string
+Weight: float
+barrel: Barrel
+size: int
+apples: list
+location: string
+oranges: list
+Weight: float
+Orchard: string
+Date_Picked: date
+basket: Basket
Depending on how detailed our design needs to be, we can also specify the type 
for each attribute. Attribute types are often primitives that are standard to most 
programming languages, such as integer, floating-point number, string, byte, or 
Boolean. However, they can also represent data structures such as lists, trees, or 
graphs, or most notably, other classes. This is one area where the design stage can 
overlap with the programming stage. The various primitives or objects available in 
one programming language may be somewhat different from what is available in 
other languages.
Usually, we don't need to be overly concerned with data types at the design stage, as 
implementation-specific details are chosen during the programming stage. Generic 
names are normally sufficient for design. If our design calls for a list container type, 
the Java programmers can choose to use a 
LinkedList
or an 
ArrayList
when 
implementing it, while the Python programmers (that's us!) can choose between the 
list
built-in and a 
tuple
.
In our fruit-farming example so far, our attributes are all basic primitives. However, 
there are some implicit attributes that we can make explicit—the associations.
For a given orange, we might have an attribute containing the basket that holds
that orange.

Download 2,95 Mb.

Do'stlaringiz bilan baham:
1   ...   12   13   14   15   16   17   18   19   ...   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