Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 11-22-2008, 05:22 PM   #1
Registered: Nov 2006
Distribution: xubuntu
Posts: 455

Rep: Reputation: 31

Hi there,

I actually want to make a Java car park which will accept a number of cars. When a car is entering the park it must decide when to leave. My main problem is how to check when a car must leave. Imagine that the cars will be placed in a vector. Every car will have a time that got in and a time to will get out. Ideally if the time to get out is greater equals than the current runtime it must leave.
I am familiar with the observer/observable design pattern but to be honest I do not really know how to implement it in this case.
I will be really happy if anyone can give me any idea.

Many thanks.
Old 11-22-2008, 05:39 PM   #2
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Off the top of my head, I'd suggest:

1. You would have some interface, e.g. "IObservable"
2. Your "cars" would implement "IObservable"
3. Each car would register itself with the "Observer" (the car park), invoking (for example) a "CarPark.add ()" method as it drives in.

'Hope that helps .. PSM
Old 11-22-2008, 05:41 PM   #3
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977Reputation: 1977
It's pretty hard to read this as anything other than homework as it were... We really can't explain how to design a programming assignment from the initial spec, and homework questions really aren't supposed to be asked here.
Old 11-23-2008, 01:10 AM   #4
LQ Guru
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
You may want to read up on DelayQueue, it takes most of the work out of your hands.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
example of RMI, Observer & Factory Patterns, TransferObject, Model View Controller manolakis Programming 3 10-27-2007 10:09 AM
Observer added ??? Chikne Slackware 1 11-25-2006 04:09 AM
new observer emarald Member Intro 1 05-03-2006 04:09 PM
page observer delos Linux - Software 2 01-25-2005 08:35 AM
need some advice on c++ observer design pattern digitized_funk Programming 1 11-13-2003 11:39 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:04 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration