• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Elevator Simulator

 
Benjoe Reyes
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
-Barry
 
chanakya khatri
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
barry

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"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Benjoe Reyes
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes cindy, i am using composition
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Benjoe Reyes
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic