Käynnissä

elevator class coding in c+++

this is the instructions :

Before writing the actual ‘run’ function of the elevator, write two functions for the elevator class that will be necessary for the run function to operate correctly. First, you will need to be able to search the array of passenger’s destinations and return the next floor the elevator needs to stop at. Next, you will need to be able to search the passenger array and see which passenger(s) need to exit at the current stop.

1. Clean up the code from last time by creating a #define for the maximum number or passengers. This helps by allowing you to change a number in one location, rather than all over your code to modify the maximum number of passengers. In ‘Elevator.h’ after the #include, add #define MAX_PASSENGERS 5. Then, everywhere that the number 5 was used in loops and if statements, change it to MAX_PASSENGERS.

2. Add a function to the Elevator class definition called ‘findNextFloor’. This function does not need any input arguments, but should return the integer value of the next floor, based on the passenger destinations.

3. Add a function to the Elevator class definition called ‘findNextPassenger’. This function requires an input argument of the current floor of the elevator. It should return the index of the passenger array of a passenger that needs to get off at that floor passed as the input argument. If no passengers are getting off at this floor, it should return the value -1.

4. Next, switch to the ‘[url removed, login to view]’ file to add the implementation of these two functions.

5. The function ‘findNextFloor’ needs to search through the passenger[ ] array and find which passenger has the lowest destination floor. This value needs to be returned from the function. This can be accomplished with a FOR-LOOP incrementing through each index of the array, keeping track of the smallest value.

6. The function ‘findNextPassenger’ needs to have an input argument of a certain floor. The function will search through the passenger array, and when it finds a passenger whose destination matches the input floor, it will return that passenger’s index in the array. This can be accomplished with a FOR-LOOP also that increments through each index of the array until it finds a match and returns that index. If no match is found the function should return -1, signaling that no more passengers are getting off at this floor.

7. Now, go back to the Elevator class definition and add a function called ‘runElevator’. This function does not need any input arguments or return value.

8. Switch back to the Elevator class implementation to implement the ‘runElevator’ function. This is the function that will deliver all the passengers to their desired floors. Take a look at the pseudo code below to help visualize the approach to doing this

If there are passengers

While there are passengers

-find the next floor to stop at

-move the elevator to that floor

-display a message saying the next stop

While there are passengers that need to exit at this floor

-find the next passenger that needs to exit

-display a message saying which person exited

-mark that spot in the elevator as empty

-decrement the number of passengers

-display the current elevator information

-reset elevator to first floor

Else

Display an error message saying there are no passengers

9. After creating the ‘runElevator’ function, go to the main function and add a third menu option for running the elevator. This is as simple as calling your Elevator class function ‘runElevator’ after the user selects option 3. Also, test when you change MAX_PASSENGERS to a different number.

Taidot: C-ohjelmointi, C++ -ohjelmointi, sähkötekniikka, Mikrocontroller, Objective C

Näytä lisää: elevator code, code elevator, elevator coding, writing file, third person writing, pseudo writing, programming definition, loops programming, get help programming, get coding, functions programming, function programming, loop programming, else programming, elevator display, definition programming, define programming

About the Employer:
( 4 reviews ) Melbourne, United States

Projektin tunnus: #1686421

15 freelanceria on tarjonnut keskimäärin 31 $ tähän työhön

it2051229

Hi, kindly check your inbox for my inquiries. Thanks.

30 $ USD 1 päivässä
(67 arvostelua)
5.0
msabouri

I can help you

30 $ USD 1 päivässä
(30 arvostelua)
4.7
honeypotant

I can do it. Thanks.

35 $ USD 1 päivässä
(8 arvostelua)
4.6
minhtridn2001

Willing to help you in this project. Best regards, Tri

30 $ USD 1 päivässä
(16 arvostelua)
4.3
duchuyctlk

Hi. I am ready to work. Pls read PMB for more detail.

30 $ USD 1 päivässä
(25 arvostelua)
4.1
buzzcoder

Let me help you, kindly check your pm,thanks.

30 $ USD 1 päivässä
(10 arvostelua)
4.1
aleexaibi

hi i am an expert programmer can easily handle your job. :)

30 $ USD 1 päivässä
(13 arvostelua)
3.5
sherazi11

hi please check your PM

30 $ USD 3 päivässä
(2 arvostelua)
3.0
umarghaffar

hi i can do it.

35 $ USD 2 päivässä
(3 arvostelua)
2.9
howtobeahacker

I write many C/C++ program, so this is not an odd for me. Pls give me this project. I wanna some portfolio for my freelancer.

30 $ USD 1 päivässä
(1 arvostelu)
2.4
coderz01

Hello. I can help you.

35 $ USD 1 päivässä
(2 arvostelua)
2.2
sherwinfer

I can do it.

30 $ USD 1 päivässä
(3 arvostelua)
0.0
LI9V8c4Jt

Custom Software Development - <B><i>The Administrator removed this message for containing contact details which breaches our Terms and Conditions</i></B>

35 $ USD 1 päivässä
(0 arvostelua)
0.0
mmukulsharma

Hi i am experienced c/c++ programmer i can do this for you please check PMB

35 $ USD 0 päivässä
(0 arvostelua)
1.8
Kobla

Hi, that's easy task, check PM.

30 $ USD 1 päivässä
(0 arvostelua)
0.0
xerxes87

I have read your project description and I think I can do this project. Consider hiring me when you do.

30 $ USD 3 päivässä
(0 arvostelua)
0.0