• Post Reply Bookmark Topic Watch Topic
  • New Topic

parking system project taking //out of time  RSS feed

 
Fares Bougara
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

i'm a student in a computer science college, it's my second year now, and we just started studying java using eclipse

we got a project this week and we had  one week to finish it which sais:

"We want to build a set of classes that make it possible to manage a car park of multi-storey vehicles.
Each floor of this parking lot consists of a series of corridors numbered from 1 to the number of existing corridors. Each corridor consists of a set of places numbered from 1 to the number of places available.

a menu is required which contains :
1. Vehicle entry (allows to occupy a free space, treat the ordinary case, large and very large)
2. Reserve place (to reserve a place)
3. Parking Status (Displays parking status to search for a free space)."



So i spent a lot of time trying to finish it, but i couldnt.

I didn't know how to start, i tried to create a 'place' class with private properties, making the gets and sets methods,constructors and everything that ive learned so far, moved out to inheritence to do some other classes like floor and...i just couldnt imagine how can i do it.

I tried to draw thing out and do that thing called 'from bottom to top', but it didnt end up well.

even though i have two days left, all i'm asking if you can guide me by few steps so i can do my best to finish it in two days.

thank you
 
Campbell Ritchie
Marshal
Posts: 56533
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Maybe you could start by telling us how many classes you have, and their names.
 
Fares Bougara
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Welcome to the Ranch

Maybe you could start by telling us how many classes you have, and their names.


thank you, well i don't know how many classes should i have, but i thought of :

place : which has more than a type, you know  for: medium / large / very large vehicles

lane : which has the main methods i think like free a spot or reserve one ..

floor

parking


which i think is essentiel, but i saw a friend of mine talking about two additional classes

reserved place

usable place

i'm looking forward for your response
 
Carey Brown
Saloon Keeper
Posts: 3310
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fares Bougara wrote:thank you, well i don't know how many classes should i have, but i thought of :
place : which has more than a type, you know  for: medium / large / very large vehicles
lane : which has the main methods i think like free a spot or reserve one ..
floor
parking

which i think is essentiel, but i saw a friend of mine talking about two additional classes
reserved place
usable place
i'm looking forward for your response


A CarPark
has Floor's
can reserveSpace()
can findAvailableSpace()
can reportStatus()

A Floor
has Corridor's

A Corridor
has Place's

Enum Size
medium, large, very large

A Place
has available or reserved
has Size

Just my quick assessment.
Don't know how this would fit your requirements, but alternatively

A CarPark
has Place[<floor>][<corridor>][<space>]
 
Fares Bougara
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carey Brown wrote:
Fares Bougara wrote:thank you, well i don't know how many classes should i have, but i thought of :
place : which has more than a type, you know  for: medium / large / very large vehicles
lane : which has the main methods i think like free a spot or reserve one ..
floor
parking

which i think is essentiel, but i saw a friend of mine talking about two additional classes
reserved place
usable place
i'm looking forward for your response


A CarPark
has Floor's
can reserveSpace()
can findAvailableSpace()
can reportStatus()

A Floor
has Corridor's

A Corridor
has Place's

Enum Size
medium, large, very large

A Place
has available or reserved
has Size

Just my quick assessment.
Don't know how this would fit your requirements, but alternatively

A CarPark
has Place[<floor>][<corridor>][<space>]


hello, thanks for your reply, that was really helpful

the thing is i dont how how to link these classes together, i mean what should inherit what, what class should fill the park, what class should hold certain methods in

i know it's not really a questionlike it should be, but i really need your help to build this thing up fom scratch

i dont want it to be complicated or anything like that, just give me more things to work on and ill reply what have i done so far
 
Junilu Lacar
Sheriff
Posts: 11477
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Beware of starting bottom up. That's what you're doing when you start with classes. It's fine to start off with a set of candidates but identifying classes and then moving forward with the assumption that you need all those classes is a recipe to overengineering and unnecessary complexity.

When you have a bunch of candidate classes, back up and start drawing out a story about what the *user* of your system wants to accomplish. Once you have a coherent story outlined, then look at your list of candidate classes to see which ones can help carry out the work needed to achieve the user's goal.
 
Carey Brown
Saloon Keeper
Posts: 3310
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fares Bougara wrote:
A CarPark
has Floor's
can reserveSpace()
can findAvailableSpace()
can reportStatus()

the thing is i dont how how to link these classes together, i mean what should inherit what, what class should fill the park, what class should hold certain methods in

To determine if inheritance is required look for an "is-a" relationship between classes. In what I outlined there are no "is-a" relationships, only "has-a". A CarPark "has-a" collection of Floor's, as an example. This is called "aggregation". Something like:
One thing not clear in your requirements statement is how the Park-Floor-Corridor-Place collections get initialized.
 
Fares Bougara
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carey Brown wrote:
Fares Bougara wrote:
A CarPark
has Floor's
can reserveSpace()
can findAvailableSpace()
can reportStatus()

the thing is i dont how how to link these classes together, i mean what should inherit what, what class should fill the park, what class should hold certain methods in

To determine if inheritance is required look for an "is-a" relationship between classes. In what I outlined there are no "is-a" relationships, only "has-a". A CarPark "has-a" collection of Floor's, as an example. This is called "aggregation". Something like:
One thing not clear in your requirements statement is how the Park-Floor-Corridor-Place collections get initialized.


that was helpful now i get when i inherit and when not.

about initialization, that thing bothers me too, it's just we have the freedom of doing that by anyway we want, there is no details about anything as you can see :

"We want to build a set of classes that make it possible to manage a car park of multi-storey vehicles.
Each floor of this parking lot consists of a series of corridors numbered from 1 to the number of existing corridors. Each corridor consists of a set of places numbered from 1 to the number of places available.

a menu is required which contains :
1. Vehicle entry (allows to occupy a free space, treat the ordinary case, large and very large)
2. Reserve place (to reserve a place)
3. Parking Status (Displays parking status to search for a free space)."




 
Junilu Lacar
Sheriff
Posts: 11477
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why even think about inheritance relationships right now? Do you have any compelling reasons to justify creating a hierarchy at this point? Again, I think you are falling into the trap of trying to model the real world in your object model. You can get caught up in many what-ifs and what-abouts by following this path.

Back up now and start laying out a story for what your user wants to do with your software. Then relate that story to responsibilities. Then assign those responsibilities to one or more candidate classes. Then see how it works.

Your initial design will almost always be incorrect. So you have to experiment and see what works. As you add more responsibilities and assign them to objects, you will invariably discover inconsistencies in the semantics of the methods and the ideas the classes/objects represent. This is where it's important to understand principles like SOLID, DRY, and SLAP, and the Law of Demeter. This is where testing and refactoring are critical, when you're exploring and discovering a suitable object model that will make sense in the context of your problem.

You cannot create an object model without putting it into the context of the problem that it will be applied to. Thinking about inheritance relationships at this juncture is doing just that and I can almost guarantee that you're headed towards failure unless you stop and figure out what the context is first.
 
Junilu Lacar
Sheriff
Posts: 11477
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Start with your menu. It has three items listed. Detail out the story for each menu item. What does the user input?  What information is needed? How does a selection by the user result in actions/behaviors of the system being invoked? What changes in the system's state as a result of the actions /behavior invoked?

These are all details that you'll need to define first so that you can get a better idea of what objects to will be responsible for carrying out the actions/behavior required of the system.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!