[Tutor] Re: Classes!Classes!Classes!

Christopher Grove cgrove@execpc.com
Tue, 21 Dec 1999 17:10:21 -0600


I have just started investigating Python, and want to jump in with class
questions (to verify if I have gotten to the 'aha!' stage mentioned
earlier.

Can classes be composed of other (sub)classes?
Can classes be composed of multiple copies of the same (sub)class?
 
[I apologize for bastardizing any terminology here, I am trying to put
it in my own words (because they are what I understand best).]

My self-determined example is house design and definition:

House(class)
        Living room(class)
               room(class)[1]
               light(class)[0..n]
               lr furniture  (or would I have multiple classes here,
sofas, chairs, tables, etc)
               color (or would these be attributes of the floor,
ceiling, walls)
        Kitchen(class)
               room(class)
               light(class)
               kitchen furniture
               kitched appliances
               .        
        Bathroom(class)[1..n]
               .
        Dining room(class)
               .
        Bedroom(class)[1..n]
               room(class)
               light(class)
               bedroom furniture
               .
               .
               
               Room(class)
                   Ceiling(class)[1]
                   Floor(class)[1]
                   Wall(class)[1..n]
                   description
                   dimensions
              .
              .
                   Ceiling(class)
                       Composition
                       Color
                       Light(class)[0..n]
                       Fan(class)[0..n]
                       Dimension
                   Wall(class)
                       Composition
                       Color
                       Dimension
                       Window(class)[0..n]
                       Door(class)[0..n]
                       Light(class)[0..n]


Lights can be part of the ceiling or wall, or free standing.  Can the
(sub)class defintion be placed at different levels in the class
heirarchy?

Do I have to (should I) segment walls (i.e. composition, part of the
wall painted, part wall papered, or part painted and part wainscoated,
or part ...)?

I suppose if I were designing a mansion, I'd have the opportunity for
multiple kitchens, etc.