Develop a high-quality, object-oriented C++ program that performs a simulation using a heap implementation of a priority queue.
Please help me design a Airworthy class in C++. THANK YOU!
Develop a high-quality, object-oriented C++ program that performs a simulation using a heap implementation of a priority queue.
A simulation creates a model of a real-world situation, allowing us to introduce a variety of conditions and observe their effects. For instance, a flight simulator challenges a pilot to respond to varying conditions and measures how well the pilot responds. Simulation is frequently used to measure current business practices, such as the number of checkout lines in a grocery store or the number of tellers in a bank, so that management can determine the fewest number of employees required to meet customer needs.
Airlines have been experimenting with different boarding procedures to shorten the entire boarding time, keep the flights on-time, reduce aisle congestion, and make the experience more pleasant for passengers and crew. A late-departing flight can cause a domino effect:
- the departure gate is tied up and cannot be used by other landing or departing flights,
- passengers on board the late flight may miss connecting flights and require rebooking and possibly overnight arrangements (meals and lodging)
- passengers complain about being late, and/or about having to rearrange their plans.
Thus, late flights have a huge operational impact.
For this assignment, we will simulate boarding procedures for Airworthy Airlines. The Airline's current procedure is as follows:
- pre-board in the following order:
- families with young children or people who need help (e.g., wheelchair)
- first class and/or business class passengers
- elite passengers (frequent fliers) and those passengers seated in exit rows
- conduct general boarding in reverse, from the back of the plane to the front in the following order:
- rows 23-26
- rows 17-22
- rows 11-16
- rows 5-10
Airworthy is considering revising their boarding procedure such that general boarding is done randomly, meaning the first passenger in line for general boarding is the first passenger to board (i.e., general boarding passengers all have the same priority). Airworthy suspects this random general boarding method will improve the flow of passengers, getting them on board and seated more quickly. It is also less labor-intensive for Airworthy's customer service agents because it significantly reduces the number of boarding announcements required and eliminates confrontations with customers trying to board "out of turn." Note that the revision is to general boarding only. The pre-boarding procedures will not be changed.
Develop an Airworthy class that contains the following data members:
- exactly one priority queue where the priority is set using Airworthy's previous boarding procedure
- exactly one priority queue where the priority is set using Airworthy's new random boarding procedure
- the amount of time, in seconds, required to board a plane using Airworthy's previous boarding procedure
- the amount of time, in seconds, required to board a plane using Airworthy's new random boarding procedure
You may use additional attributes, as needed. The Airworthy class must include methods to support the following functions of the class:
- a constructor
- read the data from the input file
- load the two priority queues
- run the simulation
When running the simulation, assume that:
- A passenger who is not blocked by another passenger requires one second to board.
- A passenger is blocked when the previous passenger is sitting in the same row or a row closer to the front of the plane. A blocked passenger requires 25 seconds to board
HeapException.cpp:
#include "HeapException.h"
HeapException::HeapException(const string& msg)
: logic_error("Heap Exception: " + msg) {
}
HeapException.h:
#ifndef HEAPEXCEPTION_H
#define HEAPEXCEPTION_H
#include <stdexcept>
#include <string>
using namespace std;
class HeapException : public logic_error {
public:
HeapException(const string& msg = "");
};
#endif /* HEAPEXCEPTION_H */
HeapADT:
#ifndef HEAPADT_H
#define HEAPADT_H
template <class T>
class HeapADT {
public:
virtual bool isEmpty() const = 0;
virtual int getItemCount() const = 0;
virtual T peek() const = 0;
virtual bool add(const T& newItem) = 0;
virtual bool remove() = 0;
virtual void clear() = 0;
};
#endif /* HEAPADT_H */
ArrayMaxHeap.h:
#ifndef ARRAYMAXHEAP_H
#define ARRAYMAXHEAP_H
#include "HeapADT.h"
template <class T>
class ArrayMaxHeap : public HeapADT<T> {
public:
ArrayMaxHeap();
virtual ~ArrayMaxHeap();
bool isEmpty() const;
int getItemCount() const;
T peek() const;
bool add(const T& newItem);
bool remove();
void clear();
private:
static const int ROOT_INDEX = 0;
static const int CAPACITY = 5000;
int itemCount;
T* items;
int getLeftChild(int currNode) const;
int getRightChild(int currNode) const;
int getParent(int currNode) const;
bool isLeaf(int currNode) const;
void percolateDown(int subtree);
};
#include "ArrayMaxHeap.cpp"
#endif /* ARRAYMAXHEAP_H */
Trending now
This is a popular solution!
Step by step
Solved in 2 steps