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???
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
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.
Joined: Apr 24, 2002
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...
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.
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