Next / Previous / Contents / TCC Help System / NM Tech homepage

28. class Room: Room information

A small object that holds room information.

hwscan3.py
# - - - - -   c l a s s   R o o m   - - - - -

class Room:
    '''Represents data about one room in the report parameters file.

      Exports:
        Room ( roomType, roomPrefix, roomFull ):
          [ (roomType is the room's type as a string) and
            (roomPrefix is the prefix for clients in that room) and
            (roomFull is the full name of the room) ->
              return a new Room object with those attributes ]
        .roomType:   [ as passed to constructor, read-only ]
        .roomPrefix: [ as passed to constructor, read-only ]
        .roomFull:   [ as passed to constructor, read-only ]
        .roomFullType:
          [ text corresponding to self.roomType, e.g.,
            "open lab" or "classroom" ]
        .ROOM_OPEN:  [ roomType for open labs ]
        .ROOM_CLASS: [ roomType for classrooms ]
    '''
    ROOM_OPEN  =  'o'
    ROOM_CLASS  =  'c'
    ROOM_TYPE_MAP  =  { ROOM_OPEN: "open lab", ROOM_CLASS: "classroom" }
    def __init__ ( self, roomType, roomPrefix, roomFull ):
        '''Constructor for Room'''
        self.roomType      =  roomType
        self.roomPrefix    =  roomPrefix
        self.roomFull      =  roomFull
        self.roomFullType  =  self.ROOM_TYPE_MAP[roomType]