Please help me design a Passsenger 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), etc., and
- 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 a Passenger class that stores the following data for an Airworthy Airlines passenger:
- key - the priority value for the PriorityQueue
- passenger's last name
- passenger type, a character, where 'H' is a child or passenger who needs help in boarding, 'E' is an elite passenger (frequent flyer), and 'G' is a general boarding passenger
- row where passenger is seated; must be a number between 1 and 26, where rows 1-4 are first class and rows 10 and 11 are exit rows
Include a constructor and accessors and mutators for each attribute. In addition, you MUST include methods that overload the < and > operators. You may include other methods, if needed.
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();
//interface methods
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 nowThis is a popular solution!
Step by stepSolved in 2 steps
- C++arrow_forwardWhat are the advantages and disadvantages of adopting user-defined ordinal kinds when it comes to data types? There are various positives and negatives associated with using an associative array, all of which will be covered in more depth below.arrow_forwardWrite a C++ program that simulates a two-dimensional random walk along a grid that has M by N function parameters.The walker moves in one of four directions. The walker chooses the direction randomly. The walker cannot move off the grid. The function ends when the walker visits every grid position at least once. The function returns a dynamic structure that is an ordered record of the walker's positions over time. The first element of the structure is the walker's first position. The last element is the walker's last position.arrow_forward
- Data structures are defined as: What does the term "abstract data type" refer to? Could you elucidate your response with an example?arrow_forwardJava Assignment: Experiment with naming rules in Java Does the language use static or dynamic scoping? Can scopes nest? Are they open or closed? Does the scope of a name encompass the entire block in which it is declared, or only the portion after the declaration? How does one declare mutually recursive types or subroutines? Can subroutines be passed as parameters, returned from functions, or stored in variables? If so, when are referencing environments bound? Justify your answers with suitable code snippet and its output.arrow_forwardWhat is meant by an Abstract Data Type (ADT)? What are the advantages of ADTs? How does the concept of inheritance simplify problem solving?arrow_forward
- Explore the concept of custom operator overloading in C++ and its implications for creating user-defined data types with unique behaviors. Provide an example of such an implementation.arrow_forwardI am learning OOD in C++. Is there a good example of a dice game that can help teach me how to understand C++ and object oriented design? Concepts such as Using classes abstract data types including: using constructors and destructors, using pointers, using inheritance, providing for exception handling, and using recursive definitions? I myself would like to come up with a game that titled 'high roller' where a player could play a computer where each have 3 dice and the highest score wins. Pretty simple but I am still learning these concepts. Thank you,arrow_forwardPlease help me with this 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…arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY