0% found this document useful (0 votes)
7 views2 pages

Object Oriented Programming

Uploaded by

jc52pv4mpq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Object Oriented Programming

Uploaded by

jc52pv4mpq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

sum_of_prices = 0

def __init__(self, b, m, y, p):


self.__brand = b
self.__model = m
self.__year = y
self.__price = p

def setBrand(self, b):


self.__branclass Car :
d = b
def getBrand(self):
return self.__brand
def setModel(self, m):
self.__model = m
def getModel(self):
return self.__model
def setYear(self, y):
self.__year = y
def getYear(self):
return self.__year
def setPrice(self, p):
self.__price = p
def getPrice(self):
return self.__price
Car.sum_of_prices += p

car1 = Car( "BMW", "X3", "2022", 43700)


car2 = Car( "Mercedes", "class c", "2022", 45000)
car3 = Car( "Audi", "RS3", "2022", 60000 )

print(car1.getModel())
print(car2.getModel())
print(car3.getModel())

class Car :
sum_of_prices = 0

def __init__(self, b, m, y, p):


self.__brand = b
self.__model = m
self.__year = y
self.__price = p
def setprice(self, p):
price_difference = abs(p - self.__price)

rel_difference = price.difference/self.__price

if rel_difference > 0.05 :


print("error the price is not updated , the changment of the price should be
more than 5%.")
else :
car.price_sum -= self._price
self.__price = p
car.price_sum += p
def setBrand(self, b):
self.__brand = b
def getBrand(self):
return self.__brand
def setModel(self, m):
self.__model = m
def getModel(self):
return self.__model
def setYear(self, y):
self.__year = y
def getYear(self):
return self.__year
def getPrice(self):
return self.__price
Car.sum_of_prices += p

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy