Skip to content

Instantly share code, notes, and snippets.

@saiprasad1996
Created September 21, 2018 11:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saiprasad1996/7290d05be9b323061f1c7f29f803dedb to your computer and use it in GitHub Desktop.
Save saiprasad1996/7290d05be9b323061f1c7f29f803dedb to your computer and use it in GitHub Desktop.
class Car:
type=None
fuelcapacity=None
mileage = None
seats = None
fuel = None
ignition = None
def start(self):
if self.fuel>1:
self.ignition = True
else:
print("Oh my bhikari dost")
def stop(self):
self.ignition = False
def drive(self, distance):
if self.ignition == True:
fuel = 0
fuel = fuel - (distance*self.mileage)
if fuel>0:
self.fuel = fuel
else:
print('Under fuel')
else:
print("Bhai gadi start to kar")
def refuel(self,qty):
newfuel = qty+self.fuel
if newfuel>self.fuelcapacity:
print("Paisa jyada ho gya ki ?")
else:
self.fuel = newfuel
def getGadiStatus(self):
print(self.type,self.fuelcapacity,self.mileage,self.seats,self.fuel,self.ignition)
def __init__(self,ignition=False,**kwargs):
self.type=kwargs['type']
self.fuelcapacity=kwargs['fuelcapacity']
self.mileage = kwargs['mileage']
self.seats = kwargs['seats']
self.fuel = kwargs['fuel']
self.ignition = ignition
mercedes = Car(type="Petrol",fuelcapacity=25,mileage=12,seats=5,fuel=0)
mercedes.getGadiStatus()
mercedes.refuel(3)
mercedes.start()
mercedes.drive(10)
mercedes.getGadiStatus()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment