-
Notifications
You must be signed in to change notification settings - Fork 0
/
elevator.h
58 lines (55 loc) · 1.96 KB
/
elevator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// UMBC - CMSC 341 - Spring 2022 - Proj1
#ifndef ELEVATOR_H
#define ELEVATOR_H
#include <string>
#include <iostream>
#include <stdexcept>
#include <stdlib.h>
using namespace std;
class Grader;//this class is for grading purposes, no need to do anything
class Tester;//this is your tester class, you add your test functions in this class
class Floor{
friend class Grader;
friend class Tester;
friend class Elevator;
public:
Floor(int floor, string passenger = ""){
// note: floors can be negative, i.e. undergraound floors
m_floorNum = floor;
m_passenger = passenger;
m_next=nullptr;
m_previous=nullptr;
}
~Floor(){}
private:
int m_floorNum;
string m_passenger;
Floor* m_next;
Floor* m_previous;
};
class Elevator{
friend class Tester;
friend class Grader;
public:
Elevator();
~Elevator();
Elevator(const Elevator & rhs);
const Elevator & operator=(const Elevator & rhs);
bool insertAtHead(int floor, string passenger="");// inserting at the head of linked list
bool insertAtTail(int floor, string passenger="");// inserting at the tail of linked list
bool move(int origin, int destination);// elevator moves from origin to destination
bool enter(int floor, string passenger);// passenger enters
string exit(int floor, string passenger);// passenger exists
bool removeFloor(int floor);//removes a node from the linked list
bool insertFloor(int floor);//inserts node in the middle of linked list
bool checkFloor(int floor);// check whether floor exists
void dump();// for debugging purposes
void clear();// deallocating the memory and reinitializes everything
private:
Floor* m_ground;// this is the head of the linked list
Floor* m_top;// this is the tail of the linked list
/******************************************
* Private function declarations go here! *
******************************************/
};
#endif