Parking Lot OO Design (Python)Python data massagerPython review_generatorPython High Score TablePython Word definition practiceSimple Hangman in PythonBakery - Python 3.4.2Python hexdump generatorOptimizing a Text-To-Speech program with a lot of repetitionPython GPA CalculatorDesign code to compute technical indicators

The baby cries all morning

How to verify if g is a generator for p?

How to be diplomatic in refusing to write code that breaches the privacy of our users

Is exact Kanji stroke length important?

Print name if parameter passed to function

Is there an Impartial Brexit Deal comparison site?

Why is delta-v is the most useful quantity for planning space travel?

How will losing mobility of one hand affect my career as a programmer?

How to avoid InDesign adding pages automatically?

Have I saved too much for retirement so far?

What is the term when two people sing in harmony, but they aren't singing the same notes?

Finding all intervals that match predicate in vector

Why are on-board computers allowed to change controls without notifying the pilots?

How can I replace every global instance of "x[2]" with "x_2"

Best way to store options for panels

Is there any reason not to eat food that's been dropped on the surface of the moon?

How can my private key be revealed if I use the same nonce while generating the signature?

Is there a problem with hiding "forgot password" until it's needed?

What are the ramifications of creating a homebrew world without an Astral Plane?

What is the oldest known work of fiction?

quarter to five p.m

Find swapfile location in Linux Mint

What defines a dissertation?

Hostile work environment after whistle-blowing on coworker and our boss. What do I do?



Parking Lot OO Design (Python)


Python data massagerPython review_generatorPython High Score TablePython Word definition practiceSimple Hangman in PythonBakery - Python 3.4.2Python hexdump generatorOptimizing a Text-To-Speech program with a lot of repetitionPython GPA CalculatorDesign code to compute technical indicators













-1












$begingroup$



Please review my code for parking lot design.



Requirements considered:



1) The parking lot can have multiple levels.
2) Each level can have 'compact','large','bike' and 'electric' spots.
3) Vehicle should be charged according to spot type, time of parking and duration of parking.
4) Should be able to add more spots to level.
5) Show the available number of spots on each level.




class parkingFloor():
def __init__(self,name):
self.name = name
self.spotTotal = 'compact':0,'large':0,'bike':0,'electric':0

self.spotTaken = 'compact':0,'large':0,'bike':0,'electric':0

self.freeSpot = 'compact':set(),'large':set(),'bike':set(),'electric':set()
self.takenSpot = 'compact':,'large':,'bike':,'electric':

def assignSpot(self,tickt):
if self.spotTaken[tickt.veh.type] >= self.spotTotal[tickt.veh.type]:
return False
for s in self.freeSpot[tickt.veh.type]:
if s.id not in self.takenSpot[tickt.veh.type]:
self.takenSpot[tickt.veh.type][s.id] = tickt
self.spotTaken[tickt.veh.type]+=1
self.freeSpot[tickt.veh.type].remove(s)
tickt.allocateSpot(s)
return True
return False

def addSpot(self,type,v):
for i in range(v):
s = spot(type)
self.freeSpot[type].add(s)
self.spotTotal[type] += v

class entryPanel():
def __init__(self,id):
self.id = id

def printTicket(self,tickt):
print('Vehicle ID ',tickt.veh.id)
print('Spot ID ',tickt.spot.id)
print('Ticket ID ',tickt.id)
print('Date Time',tickt.DateTime)

def display(self,message):
print(message)


class vehicle():
def __init__(self,id,vehType):
self.id = id
self.type = vehType


class spot():
def __init__(self,spotType):
def generateId():
# some mechanism to generate spot id
return 1
self.id = generateId()
self.type = spotType



class ticket():
def __init__(self,v1):
self.id = self.generateId()
self.veh = v1

self.spot = None
self.DateTime = self.getTime()
self.amount = 0
self.status = 'Active'
self.payment = None

def getTime(self):
time = 1234
return time

def generateId(self):
# some mechanism to generate new ticket id
new_ticket = 1
return new_ticket

def allocateSpot(self,spot):
self.spot = spot

def addPayment(self,pay):
self.status = 'Complete'
self.payment = pay

class parkingLot():
def __init__(self,name,address):
self.name = name
self.address = address
self.level = []

def addLevel(self,floor):
self.level.append(floor)

def processEntry(self,t1,gate):
for l in self.level:
if l.assignSpot(t1):
gate.printTicket(t1)
return
gate.display('No Spot Empty')

def processExit(self,tickt,gate):
def getTime():
# Gives the current time
return 3
currTime = getTime()
print('Processing fare',tickt.veh.type,tickt.spot.id,tickt.DateTime,currTime)
amountCalculated = 7
tickt.addPayment(Payment(amountCalculated))
gate.display('Payment Successful')

class Payment():
def __init__(self,amount):
self.id = 'paymentid2'
self.type = 'credit' # debit
self.time = 'paymet time'

class displayBoard():
def show(self,p):
for l in p.level:
print(l.name)
for k in l.spotTotal.keys():
print(k, l.spotTotal[k] - l.spotTaken[k])


P = parkingLot('Savita','Address')
floor1 = parkingFloor('floor1')
P.addLevel(floor1)
floor1.addSpot('compact',5)

board = displayBoard()
board.show(P)

entryPanel1 = entryPanel('1')

v1 = vehicle(1,'compact')
t1 = ticket(v1)

P.processEntry(t1,entryPanel1)
P.processExit(t1,entryPanel1)









share|improve this question







New contributor




Savita Rana is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$
















    -1












    $begingroup$



    Please review my code for parking lot design.



    Requirements considered:



    1) The parking lot can have multiple levels.
    2) Each level can have 'compact','large','bike' and 'electric' spots.
    3) Vehicle should be charged according to spot type, time of parking and duration of parking.
    4) Should be able to add more spots to level.
    5) Show the available number of spots on each level.




    class parkingFloor():
    def __init__(self,name):
    self.name = name
    self.spotTotal = 'compact':0,'large':0,'bike':0,'electric':0

    self.spotTaken = 'compact':0,'large':0,'bike':0,'electric':0

    self.freeSpot = 'compact':set(),'large':set(),'bike':set(),'electric':set()
    self.takenSpot = 'compact':,'large':,'bike':,'electric':

    def assignSpot(self,tickt):
    if self.spotTaken[tickt.veh.type] >= self.spotTotal[tickt.veh.type]:
    return False
    for s in self.freeSpot[tickt.veh.type]:
    if s.id not in self.takenSpot[tickt.veh.type]:
    self.takenSpot[tickt.veh.type][s.id] = tickt
    self.spotTaken[tickt.veh.type]+=1
    self.freeSpot[tickt.veh.type].remove(s)
    tickt.allocateSpot(s)
    return True
    return False

    def addSpot(self,type,v):
    for i in range(v):
    s = spot(type)
    self.freeSpot[type].add(s)
    self.spotTotal[type] += v

    class entryPanel():
    def __init__(self,id):
    self.id = id

    def printTicket(self,tickt):
    print('Vehicle ID ',tickt.veh.id)
    print('Spot ID ',tickt.spot.id)
    print('Ticket ID ',tickt.id)
    print('Date Time',tickt.DateTime)

    def display(self,message):
    print(message)


    class vehicle():
    def __init__(self,id,vehType):
    self.id = id
    self.type = vehType


    class spot():
    def __init__(self,spotType):
    def generateId():
    # some mechanism to generate spot id
    return 1
    self.id = generateId()
    self.type = spotType



    class ticket():
    def __init__(self,v1):
    self.id = self.generateId()
    self.veh = v1

    self.spot = None
    self.DateTime = self.getTime()
    self.amount = 0
    self.status = 'Active'
    self.payment = None

    def getTime(self):
    time = 1234
    return time

    def generateId(self):
    # some mechanism to generate new ticket id
    new_ticket = 1
    return new_ticket

    def allocateSpot(self,spot):
    self.spot = spot

    def addPayment(self,pay):
    self.status = 'Complete'
    self.payment = pay

    class parkingLot():
    def __init__(self,name,address):
    self.name = name
    self.address = address
    self.level = []

    def addLevel(self,floor):
    self.level.append(floor)

    def processEntry(self,t1,gate):
    for l in self.level:
    if l.assignSpot(t1):
    gate.printTicket(t1)
    return
    gate.display('No Spot Empty')

    def processExit(self,tickt,gate):
    def getTime():
    # Gives the current time
    return 3
    currTime = getTime()
    print('Processing fare',tickt.veh.type,tickt.spot.id,tickt.DateTime,currTime)
    amountCalculated = 7
    tickt.addPayment(Payment(amountCalculated))
    gate.display('Payment Successful')

    class Payment():
    def __init__(self,amount):
    self.id = 'paymentid2'
    self.type = 'credit' # debit
    self.time = 'paymet time'

    class displayBoard():
    def show(self,p):
    for l in p.level:
    print(l.name)
    for k in l.spotTotal.keys():
    print(k, l.spotTotal[k] - l.spotTaken[k])


    P = parkingLot('Savita','Address')
    floor1 = parkingFloor('floor1')
    P.addLevel(floor1)
    floor1.addSpot('compact',5)

    board = displayBoard()
    board.show(P)

    entryPanel1 = entryPanel('1')

    v1 = vehicle(1,'compact')
    t1 = ticket(v1)

    P.processEntry(t1,entryPanel1)
    P.processExit(t1,entryPanel1)









    share|improve this question







    New contributor




    Savita Rana is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.







    $endgroup$














      -1












      -1








      -1





      $begingroup$



      Please review my code for parking lot design.



      Requirements considered:



      1) The parking lot can have multiple levels.
      2) Each level can have 'compact','large','bike' and 'electric' spots.
      3) Vehicle should be charged according to spot type, time of parking and duration of parking.
      4) Should be able to add more spots to level.
      5) Show the available number of spots on each level.




      class parkingFloor():
      def __init__(self,name):
      self.name = name
      self.spotTotal = 'compact':0,'large':0,'bike':0,'electric':0

      self.spotTaken = 'compact':0,'large':0,'bike':0,'electric':0

      self.freeSpot = 'compact':set(),'large':set(),'bike':set(),'electric':set()
      self.takenSpot = 'compact':,'large':,'bike':,'electric':

      def assignSpot(self,tickt):
      if self.spotTaken[tickt.veh.type] >= self.spotTotal[tickt.veh.type]:
      return False
      for s in self.freeSpot[tickt.veh.type]:
      if s.id not in self.takenSpot[tickt.veh.type]:
      self.takenSpot[tickt.veh.type][s.id] = tickt
      self.spotTaken[tickt.veh.type]+=1
      self.freeSpot[tickt.veh.type].remove(s)
      tickt.allocateSpot(s)
      return True
      return False

      def addSpot(self,type,v):
      for i in range(v):
      s = spot(type)
      self.freeSpot[type].add(s)
      self.spotTotal[type] += v

      class entryPanel():
      def __init__(self,id):
      self.id = id

      def printTicket(self,tickt):
      print('Vehicle ID ',tickt.veh.id)
      print('Spot ID ',tickt.spot.id)
      print('Ticket ID ',tickt.id)
      print('Date Time',tickt.DateTime)

      def display(self,message):
      print(message)


      class vehicle():
      def __init__(self,id,vehType):
      self.id = id
      self.type = vehType


      class spot():
      def __init__(self,spotType):
      def generateId():
      # some mechanism to generate spot id
      return 1
      self.id = generateId()
      self.type = spotType



      class ticket():
      def __init__(self,v1):
      self.id = self.generateId()
      self.veh = v1

      self.spot = None
      self.DateTime = self.getTime()
      self.amount = 0
      self.status = 'Active'
      self.payment = None

      def getTime(self):
      time = 1234
      return time

      def generateId(self):
      # some mechanism to generate new ticket id
      new_ticket = 1
      return new_ticket

      def allocateSpot(self,spot):
      self.spot = spot

      def addPayment(self,pay):
      self.status = 'Complete'
      self.payment = pay

      class parkingLot():
      def __init__(self,name,address):
      self.name = name
      self.address = address
      self.level = []

      def addLevel(self,floor):
      self.level.append(floor)

      def processEntry(self,t1,gate):
      for l in self.level:
      if l.assignSpot(t1):
      gate.printTicket(t1)
      return
      gate.display('No Spot Empty')

      def processExit(self,tickt,gate):
      def getTime():
      # Gives the current time
      return 3
      currTime = getTime()
      print('Processing fare',tickt.veh.type,tickt.spot.id,tickt.DateTime,currTime)
      amountCalculated = 7
      tickt.addPayment(Payment(amountCalculated))
      gate.display('Payment Successful')

      class Payment():
      def __init__(self,amount):
      self.id = 'paymentid2'
      self.type = 'credit' # debit
      self.time = 'paymet time'

      class displayBoard():
      def show(self,p):
      for l in p.level:
      print(l.name)
      for k in l.spotTotal.keys():
      print(k, l.spotTotal[k] - l.spotTaken[k])


      P = parkingLot('Savita','Address')
      floor1 = parkingFloor('floor1')
      P.addLevel(floor1)
      floor1.addSpot('compact',5)

      board = displayBoard()
      board.show(P)

      entryPanel1 = entryPanel('1')

      v1 = vehicle(1,'compact')
      t1 = ticket(v1)

      P.processEntry(t1,entryPanel1)
      P.processExit(t1,entryPanel1)









      share|improve this question







      New contributor




      Savita Rana is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.







      $endgroup$





      Please review my code for parking lot design.



      Requirements considered:



      1) The parking lot can have multiple levels.
      2) Each level can have 'compact','large','bike' and 'electric' spots.
      3) Vehicle should be charged according to spot type, time of parking and duration of parking.
      4) Should be able to add more spots to level.
      5) Show the available number of spots on each level.




      class parkingFloor():
      def __init__(self,name):
      self.name = name
      self.spotTotal = 'compact':0,'large':0,'bike':0,'electric':0

      self.spotTaken = 'compact':0,'large':0,'bike':0,'electric':0

      self.freeSpot = 'compact':set(),'large':set(),'bike':set(),'electric':set()
      self.takenSpot = 'compact':,'large':,'bike':,'electric':

      def assignSpot(self,tickt):
      if self.spotTaken[tickt.veh.type] >= self.spotTotal[tickt.veh.type]:
      return False
      for s in self.freeSpot[tickt.veh.type]:
      if s.id not in self.takenSpot[tickt.veh.type]:
      self.takenSpot[tickt.veh.type][s.id] = tickt
      self.spotTaken[tickt.veh.type]+=1
      self.freeSpot[tickt.veh.type].remove(s)
      tickt.allocateSpot(s)
      return True
      return False

      def addSpot(self,type,v):
      for i in range(v):
      s = spot(type)
      self.freeSpot[type].add(s)
      self.spotTotal[type] += v

      class entryPanel():
      def __init__(self,id):
      self.id = id

      def printTicket(self,tickt):
      print('Vehicle ID ',tickt.veh.id)
      print('Spot ID ',tickt.spot.id)
      print('Ticket ID ',tickt.id)
      print('Date Time',tickt.DateTime)

      def display(self,message):
      print(message)


      class vehicle():
      def __init__(self,id,vehType):
      self.id = id
      self.type = vehType


      class spot():
      def __init__(self,spotType):
      def generateId():
      # some mechanism to generate spot id
      return 1
      self.id = generateId()
      self.type = spotType



      class ticket():
      def __init__(self,v1):
      self.id = self.generateId()
      self.veh = v1

      self.spot = None
      self.DateTime = self.getTime()
      self.amount = 0
      self.status = 'Active'
      self.payment = None

      def getTime(self):
      time = 1234
      return time

      def generateId(self):
      # some mechanism to generate new ticket id
      new_ticket = 1
      return new_ticket

      def allocateSpot(self,spot):
      self.spot = spot

      def addPayment(self,pay):
      self.status = 'Complete'
      self.payment = pay

      class parkingLot():
      def __init__(self,name,address):
      self.name = name
      self.address = address
      self.level = []

      def addLevel(self,floor):
      self.level.append(floor)

      def processEntry(self,t1,gate):
      for l in self.level:
      if l.assignSpot(t1):
      gate.printTicket(t1)
      return
      gate.display('No Spot Empty')

      def processExit(self,tickt,gate):
      def getTime():
      # Gives the current time
      return 3
      currTime = getTime()
      print('Processing fare',tickt.veh.type,tickt.spot.id,tickt.DateTime,currTime)
      amountCalculated = 7
      tickt.addPayment(Payment(amountCalculated))
      gate.display('Payment Successful')

      class Payment():
      def __init__(self,amount):
      self.id = 'paymentid2'
      self.type = 'credit' # debit
      self.time = 'paymet time'

      class displayBoard():
      def show(self,p):
      for l in p.level:
      print(l.name)
      for k in l.spotTotal.keys():
      print(k, l.spotTotal[k] - l.spotTaken[k])


      P = parkingLot('Savita','Address')
      floor1 = parkingFloor('floor1')
      P.addLevel(floor1)
      floor1.addSpot('compact',5)

      board = displayBoard()
      board.show(P)

      entryPanel1 = entryPanel('1')

      v1 = vehicle(1,'compact')
      t1 = ticket(v1)

      P.processEntry(t1,entryPanel1)
      P.processExit(t1,entryPanel1)






      python-3.x






      share|improve this question







      New contributor




      Savita Rana is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Savita Rana is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Savita Rana is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 11 mins ago









      Savita RanaSavita Rana

      1




      1




      New contributor




      Savita Rana is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Savita Rana is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Savita Rana is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          0






          active

          oldest

          votes











          Your Answer





          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "196"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          Savita Rana is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216290%2fparking-lot-oo-design-python%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          Savita Rana is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          Savita Rana is a new contributor. Be nice, and check out our Code of Conduct.












          Savita Rana is a new contributor. Be nice, and check out our Code of Conduct.











          Savita Rana is a new contributor. Be nice, and check out our Code of Conduct.














          Thanks for contributing an answer to Code Review Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216290%2fparking-lot-oo-design-python%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          名間水力發電廠 目录 沿革 設施 鄰近設施 註釋 外部連結 导航菜单23°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.7113923°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.71139計畫概要原始内容臺灣第一座BOT 模式開發的水力發電廠-名間水力電廠名間水力發電廠 水利署首件BOT案原始内容《小檔案》名間電廠 首座BOT水力發電廠原始内容名間電廠BOT - 經濟部水利署中區水資源局

          格濟夫卡 參考資料 导航菜单51°3′40″N 34°2′21″E / 51.06111°N 34.03917°E / 51.06111; 34.03917ГезівкаПогода в селі 编辑或修订