Question: This is question is about stack and queue, I finished stack and queue part. however, I don't know how to use the Command when I

 This is question is about stack and queue, I finished stack

and queue part. however, I don't know how to use the Command

This is question is about stack and queue, I finished stack and queue part. however, I don't know how to use the Command when I read something from the file.

It should put wait into queue, and then check Elevator status

---------------------------------------------------------------------------

when I read something from the file. It should put wait intoqueue, and then check Elevator status --------------------------------------------------------------------------- This is all header filesso far, I didn't put my queue.cpp.it's similar to stack.cpp. Commands fromfile: Command Description Someone gets in line for the elevator . Thename will be a single word WAIT PICK_UP How many people geton the elevator DROP_OFF The elevator goes up into the building .This is all header files so far, I didn't put my queue.cpp.it's similar to stack.cpp.

Commands from file: Command Description Someone gets in line for the elevator . The name will be a single word WAIT PICK_UP How many people get on the elevator DROP_OFF The elevator goes up into the building . The given number of people get off the elevator Then the elevator returns to the ground floor The status of the following is printed to the screen Is the elevator empty? Who will be the next to get off the elevator? . Who will be the next to get on the elevator? DO NOT alter either data structure INSPECTION Elevator status: The elevator is not empty. Mark will be the next person to leave the elevator. Stacy will be the next person to get on the elevator. Note, there is no exit command. You'll have to read until you reach the end of file. Here's one way of reading until you reach the end of file: while (inFileObject >> someVar) //you just successfully read something into someVar //so you can proceed or perhaps even continue reading into other variables WAIT Bart WAIT Homer WAIT Marge WAIT Lisa WAIT Maggie WAIT Fred INSPECTION WAIT Wilma WAIT Betty WAIT Barney WAIT George WAIT Jane PICK_UP 7 INSPECTION DROP_OFF 3 PICK UP 4 INSPECTION File overview: Six people get in line for the elevator Inspection occurs. The following is printed: Elevator status: The elevator is empty. No one is in the elevator. Bart will be the next person to get on the elevator. Node. Executive 1 Elevator #ifndef NODE_H #define NODE_H template class Node Node.cpp template Node::Node(T entry) 1 2 3 4 5 6 m_entry = entry; m_next = nullptr; } private: Tm_entry; Node* m_next; public: Node(T entry); T getEntry() const; void setEntry(T entry); Node* getNext() const; void setNext(Node* next); 8 9 10 11 12 template T Node::getEntry() const { return (m_entry); } 16 15 16 17 18 template void Node::setEntry(T entry) { m_entry=entys ) 17 18 19 }; #include "Node.cpp" #endif 19 20 21 template Node* Node::getNext() const return(m_next); } 23 24 25 26 27 28 29 30 template void Node::setNext(Node next) { m_next = next; } sta ction Find Packages Help stack.h i #ifndef stack_h 2 #define stack_h 3 #include "Node.h" template 5 class stack 6 { public: stack(); ~stack(); void push(T entry); 200DDDDR3 void pop(); HDDODODE2 T peek() const; bool isEmpty() const; 15 16 17 18 19 private: Node* m_top; }; #include "stack.cpp" #endif 20 stack.h queue.h i '3 4 5 6 #ifndef queue_h #define queue_h #include "Node.h" #include "stack.h" template class queue public: bool isEmpty() const; void enqueue(const T value); void dequeue(); I peekFront() const; queue(); -queue(); queue(const queue& orig); void operator=(const stack& rhs); private, Node* front; Node* back, }; #include "queue.cpp" #endif 20 21 #INCU stack.cpp #include #include using namespace std; template stack::stack() 3 4 5 7 8. 9 10 11 m_top= nullptr; } template stack:~stack() { while (! isEmpty()) { pop(); } } 13 14 15 16 18 template void stack.push(T entry) Node* temp = new Node(entry); temp->setNext(m_top); m_top= temp; } 24 26 27 template void stackpop() try if(isEmpty()) LF UTF-8 stack.cpp if(isEmpty()) throw runtime_error("Pop attempted on an empty stack"); else Node* temp; temp = m_top; m_top = m_top->getNext(); delete temp; catch (runtime_error& rte) cout T stack::peek() const 51 { 52 try if(m_top == nullptr) throw runtime_error("Peek attempted on an empty stack"); else return (m_top->getEntry()); LF UTF-8 C++1 stack.cpp Stack.cpp...p rv.. try { if(m_top == nullptr) throw runtime_error("Peek attempted on an empty stack"); else { return (m_top->getEntry()); catch (runtime_error& rte) cout bool stack::isEmpty() const 71 72 if(m_top== nullptr) 74 return true; else return false; 80 } LF UTF-8 C++14 Commands from file: Command Description Someone gets in line for the elevator . The name will be a single word WAIT PICK_UP How many people get on the elevator DROP_OFF The elevator goes up into the building . The given number of people get off the elevator Then the elevator returns to the ground floor The status of the following is printed to the screen Is the elevator empty? Who will be the next to get off the elevator? . Who will be the next to get on the elevator? DO NOT alter either data structure INSPECTION Elevator status: The elevator is not empty. Mark will be the next person to leave the elevator. Stacy will be the next person to get on the elevator. Note, there is no exit command. You'll have to read until you reach the end of file. Here's one way of reading until you reach the end of file: while (inFileObject >> someVar) //you just successfully read something into someVar //so you can proceed or perhaps even continue reading into other variables WAIT Bart WAIT Homer WAIT Marge WAIT Lisa WAIT Maggie WAIT Fred INSPECTION WAIT Wilma WAIT Betty WAIT Barney WAIT George WAIT Jane PICK_UP 7 INSPECTION DROP_OFF 3 PICK UP 4 INSPECTION File overview: Six people get in line for the elevator Inspection occurs. The following is printed: Elevator status: The elevator is empty. No one is in the elevator. Bart will be the next person to get on the elevator. Node. Executive 1 Elevator #ifndef NODE_H #define NODE_H template class Node Node.cpp template Node::Node(T entry) 1 2 3 4 5 6 m_entry = entry; m_next = nullptr; } private: Tm_entry; Node* m_next; public: Node(T entry); T getEntry() const; void setEntry(T entry); Node* getNext() const; void setNext(Node* next); 8 9 10 11 12 template T Node::getEntry() const { return (m_entry); } 16 15 16 17 18 template void Node::setEntry(T entry) { m_entry=entys ) 17 18 19 }; #include "Node.cpp" #endif 19 20 21 template Node* Node::getNext() const return(m_next); } 23 24 25 26 27 28 29 30 template void Node::setNext(Node next) { m_next = next; } sta ction Find Packages Help stack.h i #ifndef stack_h 2 #define stack_h 3 #include "Node.h" template 5 class stack 6 { public: stack(); ~stack(); void push(T entry); 200DDDDR3 void pop(); HDDODODE2 T peek() const; bool isEmpty() const; 15 16 17 18 19 private: Node* m_top; }; #include "stack.cpp" #endif 20 stack.h queue.h i '3 4 5 6 #ifndef queue_h #define queue_h #include "Node.h" #include "stack.h" template class queue public: bool isEmpty() const; void enqueue(const T value); void dequeue(); I peekFront() const; queue(); -queue(); queue(const queue& orig); void operator=(const stack& rhs); private, Node* front; Node* back, }; #include "queue.cpp" #endif 20 21 #INCU stack.cpp #include #include using namespace std; template stack::stack() 3 4 5 7 8. 9 10 11 m_top= nullptr; } template stack:~stack() { while (! isEmpty()) { pop(); } } 13 14 15 16 18 template void stack.push(T entry) Node* temp = new Node(entry); temp->setNext(m_top); m_top= temp; } 24 26 27 template void stackpop() try if(isEmpty()) LF UTF-8 stack.cpp if(isEmpty()) throw runtime_error("Pop attempted on an empty stack"); else Node* temp; temp = m_top; m_top = m_top->getNext(); delete temp; catch (runtime_error& rte) cout T stack::peek() const 51 { 52 try if(m_top == nullptr) throw runtime_error("Peek attempted on an empty stack"); else return (m_top->getEntry()); LF UTF-8 C++1 stack.cpp Stack.cpp...p rv.. try { if(m_top == nullptr) throw runtime_error("Peek attempted on an empty stack"); else { return (m_top->getEntry()); catch (runtime_error& rte) cout bool stack::isEmpty() const 71 72 if(m_top== nullptr) 74 return true; else return false; 80 } LF UTF-8 C++14

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!