Question: Description of program: You are to write a java program named elevator.java that simulates one elevator services in a 12-floor building using the Array List

Description of program: You are to write a java program named elevator.java that simulates one elevator services in a 12-floor building using the "Array List data structure. NOTE: There is only one elevator working this building.

Here are some requirements for the program:

1. The floors of the building are numbered 1 to 12.

2. At the start of the program, randomly generate 8 of the 12 floors to stop at while going up. These MUST be placed in an ArrayList which should be sorted in ascending order. Also generate another set of 5 numbers representing floors to stop at when going down and place it in another ArrayList. Sort this ArrayList in descending order.

3. Also at the start of the program the elevator must be located on the 1st floor and the first request is made from the ArrayList which must be a request to go up.

4. From the 1st floor, the elevator can only go in one direction up. And from the 12th floor the elevator can only go in one direction down. For the other floors, the elevator can go in either direction i.e. if it is going down when you get on and you want to go up and the down ArrayList is empty, then the elevator could start going up from that floor. The same will be true if the elevator is going up when you get on, and you want to go down and the up ArrayList is empty, then it can start going down from that floor.

5. The direction in which the elevator is going must be known at all times and the floor to which it is going. If the elevator is going up, the request could be anywhere from floor 2 to 12. If it is going down, it can be from 11 to 1, with 1 being the default.

6. The location of the elevator must be known at all times. The program should provide output regarding the current floor, whether the elevator is going up or down, which floor it is starting from and which floor it is going to, as the following output will show:

7. Each time you stop at a floor, you must stay there for 3 seconds (allowing the people to either enter the elevator or leave the elevator). Display this time in a counting format as well as an appropriate message. The elevator must take 2 seconds to move from one floor to another. No need to display this time.

8. It must also display the request structures requests for going up and down as shown above.

9. Request for the elevator must be randomly generated and placed in an up ArrayList and a down ArrayList (NO DUPLICATE VALUES ALLOWED). So the ArrayList size must be 12. Carry out the generation at the beginning of the program.

10. Every time the elevator stops at a floor, it should check the relevant request ArrayList to see which floor it should stop at next. It should then delete that floor from the request ArrayList when it stops at that floor.

11. Any other functions that you could implement that would make the elevator operation as realistic as possible.

12. Give the user the option to run the program again and again, etc.

Output:

Description of program: You are to write a java program named elevator.java

that simulates one elevator services in a 12-floor building using the "Array

List data structure. NOTE: There is only one elevator working this building.

Note: Please make sure the Array List data structure is used for this Java program.

11 Randomly generated 10 10 11 Sorted ArrayList Down 3 5 89 12 Randomly generated ArrayList 12 9 3Sorted ArayList Starting at floor 1 Going up: now at floor 2 Stopping at floor 2 for 3 seconds 1, 2,3 Starting at floor 2 Going up: now at floor 3 Stopping at floor 3 for 3 seconds 1,2,3 Starting at floor 3 Going up: now at floor 4 Stopping at floor 4 for 3 seconds 1,2,3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!