Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #object for the vehicle
- class vehicles(object):
- def __init__(self,name):
- print ("Database initialised") #initialise all variables
- make = ""
- model= ""
- year = 0
- cost = 0
- mileage = 0
- type_of_v = ""
- sold = False
- self.make = ""
- self.model= ""
- self.year = 0
- self.cost = 0
- self.mileage = 0
- self.type_of_v = ""
- self.sold = False
- self.will_it_blend = False
- def new_entry(self): #takes all required information and records it
- make = str(input("Make of vehicle? ")).upper()
- self.make = make
- model = str(input("Model of vehicle? ")).upper()
- self.model = model
- year = int(input("What year is the vehicle? "))
- self.year = year
- cost = int(input("What was the cost of the vehicle new? "))
- self.cost = cost
- mileage = int(input("What was the vehicle's mileage? "))
- self.mileage = mileage
- type_of_v = str(input("Car, truck, or motorcycle? ")).upper()
- self.type_of_v = type_of_v
- sell_cost = 0
- year_sold = int(input("What year is the vehicle being sold in? "))
- age = self.year - year_sold
- if age <= 1:
- sell_cost = (self.cost - (self.cost*0.25))
- sell_cost = ("%.2f" % sell_cost)
- elif age <= 3:
- sell_cost = cost / 2.00
- sell_cost = ("%.2f" % sell_cost)
- else:
- sell_cost = cost - (cost*0.63)
- sell_cost = ("%.2f" % sell_cost)
- self.sell_cost = sell_cost
- self.year_sold = year_sold
- self.age = age
- def price_quote(self): #Calculates just the price of the vehicle and records it
- print ("The vehicle is worth about $"+self.sell_cost+".")
- def sell(self): #calculates and records the cost of the vehicle, and the date it was sold on
- sold = True
- self.sold = sold
- month_day_sold=str(input("What day and month was this sold? ")).upper()
- year_sold = int(input("What year was this vehicle sold? "))
- age = self.year - self.year_sold
- if age <= 1:
- sell_cost = (self.cost - (self.cost*0.25))
- sell_cost = ("%.2f" % sell_cost)
- elif age <= 3:
- sell_cost = cost / 2.00
- sell_cost = ("%.2f" % sell_cost)
- else:
- sell_cost = cost / 3.00
- sell_cost = ("%.2f" % sell_cost)
- self.sell_cost = sell_cost
- self.month_day_sold = month_day_sold
- self.year_sold = year_sold
- self.age = age
- def print_full(self): #prints all the information on the entry
- self.will_it_blend = True
- try:
- self.make=str(self.make)
- except NameError:
- print ("Nothing is in this entry!")
- self.will_it_blend = False
- if self.will_it_blend == False:
- print ("")
- else:
- print ("Make: "+self.make)
- print ("Model: "+self.model)
- print ("Year: "+str(self.year))
- print ("Price new: "+str(self.cost))
- try:
- print ("Price used: "+str(self.sell_cost))
- except AttributeError:
- print ("No price has been calculated")
- print ("Mileage: "+str(self.mileage))
- if self.sold == True:
- print ("Date sold: "+self.month_day_sold+", "+str(self.year_sold))
- print ("Type of vehicle: "+self.type_of_v)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement