#!/usr/bin/python3
#======================================================================================
# This file contains both the Car class, and the CarUse.py
#======================================================================================
# The Car class
#======================================================================================
class Car:
    classType = 'Vehicle'                                       #class static attribute

    @staticmethod                                               #class static method
    def getType():
        return Car.classType

    def __init__(self, make, model):                            #constructor
        self.make  = make                                       #instance attributes
        self.model = model

    def getMake(self):                                          #instance getter methods 
        return self.make

    def getModel(self): 
        return self.model

    def __str__(self):                                          #instance method toString()
        str = "Type: " + Car.classType + ", " \
              "Make: " + self.make + ', Model: ' + self.model
        return str

#======================================================================================
# Using the Car class
#======================================================================================
#from Car import Car                            #not needed, Car class is defined above 

print("Content-type: text/html \n")                     #required response header

print('<br>')
print(Car.classType)                                    #access class attribute
print('<br>')
print(Car.getType())                                    #call static method
print('<br>')

myCar   = Car('Lexus','RX450h')                         #instantiate an object
wifeCar = Car('Audi','A4')                              #instantiate another object

print(myCar.make, myCar.model)                          #access instance attributes
print('<br>')

print("My Car make is.: " + myCar.getMake())            #access getter method
print('<br>')
print("My Car model is: " + myCar.getModel())                
print('<br>')

print("<b>My Car:</b>", myCar.__str__() )               #no need to code __str__()
print('<br>')
print("<b>My Wife's Car: </b>", wifeCar)                                  
print('<br>')




#=== link to see the python code =================================================
import os, sys
sys.path.insert(0,'/home/s/sultans/web/python/demo')
import zCode                          #import func to display the Python code
filename = os.path.abspath(__file__)  #get absolute file name 
zCode.display(filename)               #call it
#=================================================================================