Kytcs.Blogspot.com: PYthon OPA 12 may

PYthon OPA 12 may

 class ParkedVehicle:

    def __init__(self,vs,fw,pf,vp):
        self.vehicleSeq=vs
        self.fourWheeler=fw
        self.parkedFor=pf
        self.valetParking=vp
        self.parkedStatus="Parked"

class ParkingLot:
 
    def __init__(self,pv):
        self.parkedVehicle=pv
 
    def updateParkedStatus(self,lot_no):
 
        obj=self.parkedVehicle.get(lot_no,None)
        if obj==None:
            return None
        else :
            obj.parkedStatus="Cleared"
            return lot_no
 
 
 
    def getParkingCharges(self,lot_no):
        parkingCharges=0
 
        obj=self.parkedVehicle.get(lot_no,None)
 
        if obj==None:
            return None
        else:
            if obj.fourWheeler=="Yes":
                parkingCharges+=obj.parkedFor*50
            else:
                parkingCharges+=obj.parkedFor*30
 
            if obj.valetParking=="Yes":
                parkingCharges+=10
 
            return parkingCharges
 
 
 
 
N=int(input())
 
qewdkl={}
for dog in range(N):
 
    vs=int(input())
    fw=input()
    parkedfor=float(input())
    vp=input()
    lotno=int(input())
 
    q[lotno]=ParkedVehicle(vs,fw,parkedfor,vp)
 
asd=ParkingLot(q)
 
lot=int(input())
 
 
tef=asd.updateParkedStatus(lot)
 
asd=asd.getParkingCharges(lot)
 
if tef==None:
    print ("Lot Number Invalid")
else:
    print(tef,"Cleared")
 
if asd==None:
    print("Lot Number Invalid")
else:
    print(asd)

No comments:

Post a Comment

Followers

Ad Space