Car Class Program

# define the Vehicle class
class Vehicle:
    name = ""              # initial value setting inisde the clas iteself
    kind = "car"           # initial value setting inisde the clas iteself
    color = ""             # initial value setting inisde the clas iteself
    value = 100.00         # initial value setting inisde the clas iteself
    def description(self): # creating function inside the class amd return as string
        desc_str = "%s is a %s %s worth $%.2f." % (self.name, self.color, self.kind, self.value)
        return desc_str
     
     
car= Vehicle()             # creates a object [car1] for class vehicle
print car.description()    # using created object calling the function inside class


car1 = Vehicle()           # creates a object car for class vehicle
car1.name = "Fer"          # using object[car1] variables on the class vehicle is assigned
car1.color = "red"         # using object[car1] variables on the class vehicle is assigned
car1.kind = "convertible"  # using object[car1] variables on the class vehicle is assigned
car1.value = 60000.00      # using object[car1] variables on the class vehicle is assigned

car2 = Vehicle()
car2.name = "Jump"
car2.color = "blue"
car2.kind = "van"
car2.value = 10000.00

print car.description()    # Using object [car] created calling the functions[description()]inside the class
print car1.description()   # Using object [car1] created calling the functions[description()]inside the class
print car2.description()   # Using object [car2] created calling the functions[description()]inside the class

No comments: