Professional Documents
Culture Documents
#define ElevatorSetup
class Elevator
{
public:
//Sensors of elevator
bool door_closed;
bool elevator_moving;
bool elevator_at_floor;
bool elevator_between_floors;
//Elevator Properties
int total_floors;
int current_floor;
int no_basement;
public:
//Control signals
time_t change_door_status(bool);
void move_elevator(int);
void stop_elevator();
//Buttons
void summon_elevator();
void go_to_floor();
};
#endif
#include <iostream>
#include "ElevatorSetup.h"
#include <time.h>
#include <windows.h>
return time(0);
}
void Elevator::summon_elevator()
{
cout << "\n\t-----------------------------------";
cout << "\n\t| Summon Elevator |";
cout << "\n\t-----------------------------------";
int floor;
do
{
cout << "\n\tEnter your current floor (0 for ground and - for basement): ";
cin >> floor;
} while (check_floor(floor));
move_elevator(floor);
void Elevator::go_to_floor()
{
int floor;
do
{
cout << "\n\tWhich floor do you want to go to (0 for ground and - for
basement): ";
cin >> floor;
} while (check_floor(floor));
move_elevator(floor);
#include <iostream>
#include <time.h>
#include "ElevatorSetup.h"
#include <windows.h>
int main(void)
{
//Taking input the elevator properties first time elevator is setup
int password;
cout << "\n\tEnter Admin Password to setup Elevator: ";
cin >> password;
int highest_floor;
cout << "\n\tEnter the highest floor: ";
cin >> highest_floor;
int no_of_basements;
cout << "\tEnter the number of basements: ";
cin >> no_of_basements;
if (menu)
{
BuddiesElevator.summon_elevator();
start_time = BuddiesElevator.change_door_status(false);
menu = false;
}
if (!menu)
{
BuddiesElevator.go_to_floor();
start_time = BuddiesElevator.change_door_status(false);
menu = true;
return 0;
}