Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Please replace:
- class Car:
- # object initialization method
- # object initializer / constructor
- def __init__(car): #Everytime, you make an object this is called! Car()
- #init... the first argument, is a reference to the object itself.
- #typically called 'self' but not required
- car.name = 'Acura'
- car.brand = 'RSX'
- car.year = '2020'
- # print ("Hello, "+ "Tim's "+ car.name +"!")
- def getyear(self):
- return self.year
- def getname(self):
- return self.name
- def getbrand(self):
- return self.brand
- # https://stackoverflow.com/questions/44726196/how-to-implement-multiple-constructors-in-python
- def main():
- # auto = Car()
- # Car() #Object initialization syntax - the class name + the argument list
- # Car()
- # Car()
- # print (Car().name)
- rsx = Car()
- print ('Tim has got a ' + rsx.getyear() + ' ' + rsx.getbrand() + ' ' + rsx.getname() + '!')
- if __name__ == "__main__":
- main()
- # pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement