Results 1 to 4 of 4
  1. #1
    CodeD is offline Member
    Join Date
    Feb 2017
    Location
    East Coast US
    Posts
    1
    Rep Power
    0

    Question Help!! Parking garage display

    Hey,

    I'm new to Java Forums and am looking for advice on coding a parking garage display. The display will have "parking spaces" and "arrows" to show the flow of traffic in the garage. The spaces should be able to receive input from a sensor to update an repaint the space. ( Green = Vacant, Red = Occupied ). I've started to code the display and I've attached what my display looks like at this point, including arrows and one space.

    I have questions for the most efficient way to create more spaces besides drawing each one, and how to allow them to receive input that will ultimately come from a sensor.

    ( I know that the arrows are wrong at the moment. I can fix that)
    -CodeD
    Attached Thumbnails Attached Thumbnails Help!! Parking garage display-screen-shot-2017-02-08-10.57.26-am.png   Help!! Parking garage display-screen-shot-2017-02-08-10.56.44-am.png  

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Help!! Parking garage display

    A suggestion: Please wrap all posted code in code tags to preserve formatting and get highlighting making it easier to read.
    Don't post images of code.

    way to create more spaces besides drawing each one
    Define a class to represent a space. Then have a list of spaces that the paintComponent method could use to draw all the spaces.
    Last edited by Norm; 02-08-2017 at 06:07 PM.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Help!! Parking garage display

    First, you have to draw each one. But you could put them in a List and then simply iterate over the list, adjusting the location. As far as receiving inputs via a sensor, that is more problematic. The obvious way is to have an interface in Java that takes input from the sensor. Unless some third party software provides that, you would have to write the driver code to interface to the sensor. An easier way would be to have the program maintain an open data connection to a server which can present the status of the parking lots in a form more digestible to Java (like an XML file or some other text file that describes the status).

    Regards,
    Jim
    Last edited by jim829; 02-08-2017 at 06:19 PM.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  4. #4
    benji2505 is offline Senior Member
    Join Date
    Sep 2014
    Location
    MA, USA
    Posts
    398
    Rep Power
    6

    Default Re: Help!! Parking garage display

    Quote Originally Posted by Norm View Post
    ... have a list of spaces that the paintComponent method could use to draw all the spaces.
    how about one 2D array per parking level?

Similar Threads

  1. Creating a "Parking Garage" with cars as objects
    By ajfonty in forum New To Java
    Replies: 2
    Last Post: 05-23-2012, 02:47 PM
  2. a parking garage program
    By jihad in forum New To Java
    Replies: 3
    Last Post: 12-24-2011, 02:06 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •