permaculture playing cards
The moose likes Java in General and the fly likes Elevator Simulator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Elevator Simulator" Watch "Elevator Simulator" New topic

Elevator Simulator

Benjoe Reyes
Ranch Hand

Joined: Apr 24, 2002
Posts: 109
is there anyone who is familiar with Deitel&Deitel's Java How To Program 3rd Ed, and have done their Elevator Simulation??? it seems that it involves classes which also have classes as attributes and these attributes have methods that interact with or call other methods of other classes. a web of criscrossing class method interaction.
i am in the process of doing it and my design was based on a premise that, after long hours of planning and coding, turns out to be wrong. all my work is for naught. would anybody give me their opinion or a general description of their approach to the project???
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Hi Benjoe,
what you seem to be describing is the use of nested (or inner) classes in this Elevator simulation. Nested classes are a "syntatic sugar" and it could
be that your solution is equally valid. Some knowledgeable programmers would say avoid nested/inner classes like the plague. (Except for anonymous classes used for event handlers).
BTW why are you looking at the solution already?

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
chanakya khatri
Ranch Hand

Joined: May 08, 2002
Posts: 59
benjoe, you can find the source code for elevator simulator on net. try searching in google. Though you might not find the exact solution of deitels book but there are plenty of other solutions available on net..that will help you in implementing this project.
Benjoe Reyes
Ranch Hand

Joined: Apr 24, 2002
Posts: 109

its not nested. its more like defining classes individually in separate files and then using them as attributes by other classes...
i need some input/ideas on how to tackle it, not the code...
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Nope - never seen this Simulation.
Sounds like you are using Composition (or perhaps Aggregation) in the design though.
[ December 16, 2002: Message edited by: Cindy Glass ]

"JavaRanch, where the deer and the Certified play" - David O'Meara
Benjoe Reyes
Ranch Hand

Joined: Apr 24, 2002
Posts: 109
yes cindy, i am using composition
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
I finally found your new thread. I hope it isn't too late to help you out. I'm still confused about what the problem is exactly. As long as one class has a reference to an object of another class, it can call all the methods it wants. Perhaps your problem is obtaining a reference to a specific object?
The code you have so far might help clarify your question. Also try to explain more clearly what you are want to do. This explanation can be in terms of the code you have. As you have probably seen, class design can be fairly tricky. My guess is that you are trying to figure out how to get the correct object references in order to communicate between the objects in your program. How you do this depends largely on how your design is set out. One common method is to pass the appropriate reference to a constructor when you create an object. You can also pass references as parameters to other functions as necessary. Mostly it depends on when you need the reference and whether or not you can afford the storage space to keep a permanent copy. Other factors include the life-time of each object and how dynamic the objects are.
Okay, I'll stop rambling now. I really think you need to post some code. Or at least explain your design in more detail. Simply listing the classes and members of each class will help a long way in clarifying your question.

Java API Documentation
The Java Tutorial
Benjoe Reyes
Ranch Hand

Joined: Apr 24, 2002
Posts: 109
Layne Lund
thanks for the interest... i accidentally found out the answer to my question (finally) from the net but i would still like your input. i have some notes in docs file i took the initaitive to send you the file thru e-mail... check if you got something from shogun6765
I agree. Here's the link:
subject: Elevator Simulator
It's not a secret anymore!