Front End: JavaScript HW #3

All Homework Must be Uploaded to it own GitHub repository. You will copy the URL Link for your GitHub Repository and Submit that link for each of your homework assignments

For Section 4, please continue with the assignments at the GitHub homework link for JS 4.

Remember to submit your finished work here via a GitHub link.

The assignment for today is to create a parking garage class. Parking Garage

Your parking garage class should have the following methods:

  • takeTicket
  • This should decrease the amount of tickets available by 1
  • This should decrease the amount of parkingSpaces available by 1
  • payForParking
  • Display a prompt() that waits for an amount from the user and store it in a variable/binding
  • If the payment variable is not empty then (meaning the ticket has been paid) then display a message to the user that their ticket has been paid and they have 15mins to leave
  • This should update the “currentTicket” object key “paid” to True
  • leaveGarage
  • If the ticket has been paid, display a message of “Thank You, have a nice day”
  • If the ticket has not been paid, display an input prompt for payment (You will need to use the prompt() method: see attached link)
  • Once paid, display message “Thank you, have a nice day!”
  • Update parkingSpaces list to increase by 1 (meaning add to the parkingSpaces list)
  • Update tickets list to increase by 1 (meaning add to the tickets list)

You will need a few attributes as well (Please be sure to use these data types):

  • tickets -> list
  • parkingSpaces -> list
  • currentTicket -> object

By the end of this project each student should be able to:

  • Explain and/or demonstrate creating classes
  • Explain and/or demonstrate creating class methods
  • Explain and/or demonstrate class instantiation

When the project is completed, commit the final changes and submit your GitHub link.

If you want to run it in your console, feel free, but if you want to run it in VS Code, feel free to use the `node filename.js` command in your terminal to execute your JS file.

Skip to content