Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7554925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:27:55+00:00 2026-05-30T11:27:55+00:00

I am working on the parking lot example, and made few assumptions as I

  • 0

I am working on the parking lot example, and made few assumptions as I design.

I have couple of questions in assigning attributes to Items/Objects.

1) If parkingSpace is not assigned by a system, i.e., user just into Lot, finds an appropriate place (car/bike/truck/handicapped) and parks his car.

I think I don’t need a ParkingSpace object, but instead, I can keep a count of no_of_free_places for each of the category_of_parking_space.

Since parking space is big, we just maintain three variables.

  • no_of_free_slots_Car
  • no_of_free_slots_Bike
  • no_free_slots_Truck
  • no_free_slots_Handicapped

when a vehicle comes in, we just decrease one of the above values (which means, of the available X places, user chooses one and parks there), & when vehicles goes out, we increase the corresponding value.
(in short, parking lot is not assigned by anyone, vehicle just goes to one of the eligible places & parks there)

2) Assuming we have a single global parking meter.
–> Should the start_time/end_time be an attribute of Vehicle?
Or
–> vehicle_id, start_time, end_time be part of ParkingMeter.

3) Assuming the need for parkingSpace object, should 4_wheeler, 2_wheeler, handicapped be a enum type, or a separate class altogether.
If its enum, we can use findEmptySlot(parkingSpace_type);
If they are separate class altogether, and ParkingLot has a method findEmptySlot();
How can we get the appropriate Slot?

ParkingMeter will be responsible to setting the vehicle’s start, end times right?

If the has multiple amounts, 1hr – 20$, 2hr – 30$, 3hr – 40$, 5hr – 50$
is it good have these part of ParkingMeter class or, include them in a separate class “ParkingPrice”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T11:27:57+00:00Added an answer on May 30, 2026 at 11:27 am

    Okay,

    1. I didn’t really understand the question, but I would indeed use an array ParkingSpace objects to describe the spaces in the park.
    2. Since the time is per vehicle, the time should be set on the vehicle.
    3. I’d use a different class for each, and each should be extending the abstract class Vehicle. It allows for flexibility with common and unique attributes of each vehicle type (serial number for all vehicles, but only 4_wheelers have doors for instance). As for how to find empty parking spaces, each ParkingSpace object would have a $takenBy property, which would hold an instance of the vehicle object occupies it. It should default to null, then, you simply iterate through the array of spaces in your ParkingLot class, and find the one with $space->takenBy == null.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a couple of design/architectural questions that always come up in our shop.
Working with Google Maps, I have the following code: var tileNames = [base, parking,
I am working on a javascript project which involves parsing xml data. I have
So, I've been asking a lot of Xpath questions recently. Sorry, but I've only
I am working on android application where i will receive a lot of data
I'm working with a wsdl file, and learning quite a lot from the whole
Specialist or generalist threads. Hi, I'm working on a system where objects go through
I have an interesting situation where certain things are working but others are not
I'm working of a web application for a car dealer. I have a Car
I converted a working Producer/Consumer Example from Thread/Runnable to Executor/Callable/BlockingQueues and using the Poison

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.