objectivesto gain experience with arrays to


Objectives:

  1. To gain experience with Arrays.
  2. To gain experience with generic algorithms.

Documentation:

  1. Explain the purpose of the program as detail as possible
  2. Develop a solution for the problem and mention algorithms to be used
  3. List data structures to be used in solution.
  4. Give a description of how to use the program and expected input/output
  5. Explain the purpose of each class you develop in the program.

Programming:

  1. For each method, give the pre and post conditions and invariant, if any 
  2. Program execution according to the requirements given 36%
  3. Naming of program as required 
  4. Print out of source code 

Description of program:

You are to write a program name elevator.java that simulates elevator services in a 12-floor building. There must be one elevator working this building.

Here are some requirements for the program:

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

2. The Initialization Phase: Randomly generate 8 floors to stop whilst going UP (No repetitions) and 5 Floors whilst going DOWN (no repetitions). USE ARRAYS :- UPARRAY and DOWNARRAY respectively. If the last stop going up was at floor 10, and a request was made from floor 12 to go down, then the elevator must go up to floor 11 to satisfy that request.

3. HINT: A good idea is to sort the UPARRAY in ascending order and sort the DOWNARRAY in descending order.

4. The elevator must be located on the 1st floor and the first request is made which must be a request to go up.

5. 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.

6. If the elevator is on a given floor and is going down, then it could be used only to go down. Thus 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 12 to 1, with 1 being the default.

7. 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:

8. To travel from one floor to another, it will take 2 seconds and the elevator will stay for 3 seconds at each floor.

9. Display at least the waiting at each floor - Flashing the count of the seconds.

Just a sample example (not ordered)

Up array (NOT SORTED)

4

2

7

9

3

6

8

10

12

5

11

Down array  (NOT SORTED)

3

5

8

9

10

6

                                   Starting at floor 1

                                        Going up: now at floor 2

                                        Going up: now at floor 3

                                        Going up: now at floor 4

                                        Going up: now at floor 5

                                     Stopping at floor 5 for 3 seconds:  1 2 3

                                     Starting at floor 5

                                         Going up: now at floor 6

                                         Going up: now at floor 7

                                         Going up: now at floor 8

                                     Stopping at floor 8 for 3 seconds: 1 2 3

                                     Starting at floor 8

                                         Going down: now at floor 7

                                         Going down: now at floor 6

                                         Going down: now at floor 5

                                         Going down: now at floor 4

                                         Going down: now at floor 3

                                     Stopping at floor 3 for 3 seconds: 1 2 3

                                    Starting at floor 3

                                       Going down: now at floor 2

                                       Going down: now at floor 1

     Do you want to run the elevator again? "Y or y" continue. "N or n" stop.

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

11.  Every time the elevator stops at a floor, it should check the relevant request array to see which floor it should stop next.

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

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

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: objectivesto gain experience with arrays to
Reference No:- TGS0501323

Expected delivery within 24 Hours