Oop Project File

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 19

#include <iostream>

#include <string>
#include <vector>
#include <fstream>
#include <sstream>

using namespace std;

const string employeeDataFile = "employee_credentials.txt";


// Forward declaration of Maintenance class
class Maintenance;

class Schedule {
private:
struct Entry {
string flightNumber;
string departureTime;
string arrivalTime;
Entry(const string& flightNumber, const string& departureTime, const
string& arrivalTime)
: flightNumber(flightNumber), departureTime(departureTime),
arrivalTime(arrivalTime) {}
};
vector<Entry> entries;
string filename;
public:
Schedule(const string& filename) : filename(filename) {
readScheduleFromFile();
}
void add_Entry(const string& flightNumber, const string& departureTime, const
string& arrivalTime) {
entries.push_back(Entry(flightNumber, departureTime, arrivalTime));
writeScheduleToFile();
}
void remove_Entry(const string& flightNumber) {
for (auto it = entries.begin(); it != entries.end(); ++it) {
if (it->flightNumber == flightNumber) {
entries.erase(it);
writeScheduleToFile();
break;
}
}
}
void display_schedule() const {
cout << "Flight Schedule:\n";
for (const auto& entry : entries) {
cout << "Flight Number: " << entry.flightNumber << "\n";
cout << "Departure Time: " << entry.departureTime << "\n";
cout << "Arrival Time: " << entry.arrivalTime << "\n\n";
}
}
string getFilename() const { return filename; }
private:
void readScheduleFromFile() {
ifstream inFile(filename);
if (inFile.is_open()) {
string flightNumber, departureTime, arrivalTime;
while (inFile >> flightNumber >> departureTime >> arrivalTime) {
entries.push_back(Entry(flightNumber, departureTime, arrivalTime));
}
inFile.close();
} else {
cout << "Unable to open schedule file.\n";
}
}

void writeScheduleToFile() {
ofstream outFile(filename);
if (outFile.is_open()) {
for (const auto& entry : entries) {
outFile << entry.flightNumber << " " << entry.departureTime << " "
<< entry.arrivalTime << "\n";
}
outFile.close();
} else {
cout << "Unable to open schedule file for writing\n";
}
}
};

class Inventory {
private:
struct Item {
string name;
int stockLevel;
bool available;
string location;
Item(const string& name, int stockLevel, bool available, const string&
location)
: name(name), stockLevel(stockLevel), available(available),
location(location) {}
};
vector<Item> items;
vector<string> passengerSelections;
public:
void manageInventory() {
cout << "Managing inventory..." << endl;
}
void add_item(const string& item, int stockLevel, bool available, const string&
location) {
items.push_back(Item(item, stockLevel, available, location));
}
void remove_item(const string& item) {
for (auto it = items.begin(); it != items.end(); ++it) {
if (it->name == item) {
items.erase(it);
break;
}
}
}
int get_Stock_Level(const string& item) const {
for (const auto& i : items) {
if (i.name == item) {
return i.stockLevel;
}
}
return -1;
}
void get_Item_Details(const string& itemName) const {
for (const auto& i : items) {
if (i.name == itemName) {
cout << "Item Name: " << i.name << ", " << "Stock Level: " <<
i.stockLevel << ", " << "Availability: " << (i.available ? "Available" : "Not
Available") << ", " << "Location: " << i.location << endl;
return;
}
}
cout << "Item not found." << endl;
}
void addPassengerSelection(const string& itemName) {
cout << "Please select the category of items you want to include:\n";
cout << "1. Beverages\n";
cout << "2. Snacks\n";
cout << "3. Meals\n";
cout << "4. Additional items (Mask, Handfrees etc)\n";
int choice;
cout << "Enter your choice: ";
cin >> choice;

switch (choice) {
case 1: {
cout << "You have selected Beverages.\n";
cout << "Available beverages:\n";
// Display a list of available beverages
cout << "1. Water\n";
cout << "2. Soda\n";
cout << "3. Juice\n";
break;
}
case 2: {
cout << "You have selected Snacks.\n";
cout << "Available snacks:\n";
// Display a list of available snacks
cout << "1. Chips\n";
cout << "2. Cookies\n";
cout << "3. Nuts\n";
break;
}
case 3: {
cout << "You have selected Meals.\n";
cout << "Available meals:\n";
// Display a list of available meals
cout << "1. Sandwich\n";
cout << "2. Salad\n";
cout << "3. Pasta\n";
break;
}
case 4: {
cout << "You have selected Additional items.\n";
cout << "Available additional items:\n";
// Display a list of available additional items
cout << "1. Mask\n";
cout << "2. Hand sanitizers\n";
cout << "3. Earphones\n";
break;
}
default:
cout << "Invalid choice. Please select from 1 to 4.\n";
return;
}

int numItems;
cout << "Enter the number of items you want to add: ";
cin >> numItems;

// Add the selected items to the passenger selections


for (int i = 0; i < numItems; ++i) {
int itemChoice;
cout << "Enter the item number to add: ";
cin >> itemChoice;
switch (choice) {
case 1:
passengerSelections.push_back("Beverage " + to_string(itemChoice));
break;
case 2:
passengerSelections.push_back("Snack " + to_string(itemChoice));
break;
case 3:
passengerSelections.push_back("Meal " + to_string(itemChoice));
break;
case 4:
passengerSelections.push_back("Additional item " +
to_string(itemChoice));
break;
}
}
}

void notifyCrew() {
cout << "Passenger selections: ";
for (const auto& item : passengerSelections) {
cout << item << ", ";
}
cout << endl;
}
};

class Maintenance {
protected:
int maintenanceID;
int aircraftID;
string scheduledDate;
string maintenanceType;
bool completed;
bool reported;
public:
Maintenance(const int& maintenanceID, const int& aircraftID,
const string& scheduledDate, const string& maintenanceType)
: maintenanceID(maintenanceID), aircraftID(aircraftID),
scheduledDate(scheduledDate), maintenanceType(maintenanceType),
completed(false), reported(false) {}
void performMaintenance() {
cout << "Performing maintenance tasks..." << endl;
}
void handle_Maintenance_report(const string& newMaintenanceID) {
maintenanceID = stoi(newMaintenanceID);
reported = true;
cout << "Maintenance report with ID " << maintenanceID << " is being
handled.\n";
updateMaintenanceRecordsToFile();
}
void complete_Maintenance() {
completed = true;
cout << "Maintenance task for aircraft " << aircraftID << " completed.\n";
updateMaintenanceRecordsToFile();
}
void updateMaintenanceRecordsToFile() {
ofstream outFile("maintenance_records.txt", ios::app);
if (outFile.is_open()) {
outFile << "Maintenance ID: " << maintenanceID << ", Aircraft ID: " <<
aircraftID
<< ", Scheduled Date: " << scheduledDate << ", Maintenance
Type: " << maintenanceType
<< ", Completed: " << (completed ? "Yes" : "No") << ",
Reported: " << (reported ? "Yes" : "No")
<< endl;
outFile.close();
cout << "Maintenance records updated.\n";
} else {
cout << "Unable to open file.\n";
}
}
void setMaintenanceIDFromUser() {
cout << "Enter maintenance ID: ";
cin >> maintenanceID;
}
void setAircraftIDFromUser() {
cout << "Enter aircraft ID: ";
cin >> aircraftID;
}
void setScheduledDateFromUser() {
cout << "Enter scheduled date: ";
cin >> scheduledDate;
}
void setMaintenanceTypeFromUser() {
cout << "Enter maintenance type: ";
cin >> maintenanceType;
}
void setCompletedFromUser() {
cout << "Is maintenance completed? (1 for yes, 0 for no): ";
cin >> completed;
}
void setReportedFromUser() {
cout << "Is maintenance reported? (1 for yes, 0 for no): ";
cin >> reported;
}
int getMaintenanceID() const { return maintenanceID; }
int getAircraftID() const { return aircraftID; }
string getScheduledDate() const { return scheduledDate; }
string getMaintenanceType() const { return maintenanceType; }
bool isCompleted() const { return completed; }
bool isReported() const { return reported; }
};

class User {
protected:
string username;
string password;
string role;
public:
User(const string& username, const string& password, const string& role)
: username(username), password(password), role(role) {}
string getUsername() const { return username; }
string getPassword() const { return password; }
string getRole() const { return role; }
void setUsername(const string& newUsername) { username = newUsername; }
void setPassword(const string& newPassword) { password = newPassword; }
void setRole(const string& newRole) { role = newRole; }
virtual void login() = 0;
virtual void signup() = 0;
};

class Employee : public User {


protected:
string name;
string contactInfo;
public:
Employee(const string& username, const string& password,
const string& name, const string& contactInfo)
: User(username, password, "Employee"), name(name),
contactInfo(contactInfo) {}
string getName() const { return name; }
string getContactInfo() const { return contactInfo; }
void setName(const string& newName) { name = newName; }
void setContactInfo(const string& newContactInfo) { contactInfo =
newContactInfo; }
virtual void login() override {
string enteredUsername, enteredPassword;
cout << "Enter username: ";
cin >> enteredUsername;
cout << "Enter password: ";
cin >> enteredPassword;
if (validateLogin(enteredUsername, enteredPassword)) {
cout << "Login successful!\n";
} else {
cout << "Invalid username or password.\n";
}
}
virtual void signup() override {
string role;
cout << "Enter role ";
cin >> role;

setRole(role);
cout << "Signup successful!\n";
}

bool validateLogin(const string& enteredUsername, const string& enteredPassword)


const {
ifstream inFile("EmployeeData.txt");
if (inFile.is_open()) {
string storedUsername, storedPassword, storedRole;
while (inFile >> storedUsername >> storedPassword >> storedRole) {
if (enteredUsername == storedUsername && enteredPassword ==
storedPassword) {
inFile.close();
return true;
}
}
inFile.close();
} else {
cout << "Unable to open employee data file for reading" << endl;
}
return false;
}

static void writeEmployeeData(const string& filename, const string& data) {


ofstream outFile("EmployeeData.txt", ios::app);
if (outFile.is_open()) {
outFile << data << endl;
outFile.close();
} else {
cout << "Unable to open employee data file for writing" << endl;
}
}

};

class Admin : public Employee {


private:
Maintenance* maintenance;
Inventory* inventory;
int maintenanceID;
int aircraftID;
string scheduledDate;
string maintenanceType;
public:
Admin(const int& maintenanceID, const int& aircraftID,
const string& scheduledDate, const string& maintenanceType,
const string& username, const string& password,
const string& name, const string& contactInfo)
: Employee(username, password, name, contactInfo),
maintenanceID(maintenanceID), aircraftID(aircraftID),
scheduledDate(scheduledDate), maintenanceType(maintenanceType),
maintenance(nullptr), inventory(nullptr) {
maintenance = new Maintenance(maintenanceID, aircraftID, scheduledDate,
maintenanceType);
inventory = new Inventory();
}

~Admin() {
delete maintenance;
delete inventory;
}

void performMaintenance() {
maintenance->performMaintenance();
}

void handleMaintenanceReport(const string& newMaintenanceID) {


maintenance->handle_Maintenance_report(newMaintenanceID);
}

void completeMaintenance() {
maintenance->complete_Maintenance();
}

void updateMaintenanceRecordsToFile() {
maintenance->updateMaintenanceRecordsToFile();
}

void addInventoryItem(const string& item, int stockLevel, bool available, const


string& location) {
inventory->add_item(item, stockLevel, available, location);
}

void removeInventoryItem(const string& itemToRemove) {


inventory->remove_item(itemToRemove);
}

int getStockLevel(const string& item) const {


return inventory->get_Stock_Level(item);
}

void getItemDetails(const string& itemName) const {


inventory->get_Item_Details(itemName);
}
void login() override {
Employee::login();
if (getRole() == "Admin") {
cout << "Admin has logged in." << endl;
}
}
void signup() override {
Employee::signup();
cout << "Admin has signed up." << endl;
}
void add_Employee(const Employee& emp) {
ofstream outfile("employee_data.txt", ios::app);
if (outfile.is_open()) {
outfile << "Username: " << emp.getUsername() << endl;
outfile << "Password: " << emp.getPassword() << endl;
outfile << "Role: " << emp.getRole() << endl;
outfile << "Name: " << emp.getName() << endl;
outfile << "Contact Info: " << emp.getContactInfo() << endl;
outfile.close();
cout << "Employee added.\n";
} else {
cout << "Unable to open file.\n";
}
}
void remove_Employee(const string& username) {
ifstream infile("employee_data.txt");
ofstream temp("temp.txt");
string line;
bool found = false;
while (getline(infile, line)) {
if (line.find(username) == string::npos) {
temp << line << endl;
} else {
found = true;
}
}
infile.close();
temp.close();
remove("employee_data.txt");
rename("temp.txt", "employee_data.txt");
if (found) {
cout << "Employee removed." << endl;
} else {
cout << "Employee not found." << endl;
}
}
void update_Employee(const string& username, const Employee& new_emp) {
ifstream infile("employee_data.txt");
ofstream temp("temp.txt");
string line;
bool found = false;
while (getline(infile, line)) {
if (line.find(username) != string::npos) {
temp << new_emp.getUsername() << "\n"
<< new_emp.getPassword() << "\n"
<< new_emp.getRole() << "\n"
<< new_emp.getName() << "\n"
<< new_emp.getContactInfo() << "\n";
found = true;
} else {
temp << line << endl;
}
}
infile.close();
temp.close();
remove("employee_data.txt");
rename("temp.txt", "employee_data.txt");
if (found)
cout << "Employee updated.\n";
else
cout << "Employee not found.\n";
}
void view_Employee_Details() {
ifstream infile("employee_data.txt");
string line;
while (getline(infile, line)) {
cout << line << endl;
}
infile.close();
}
void view_Financial_Reports() {
ifstream infile("financial_reports.txt");
string line;
while (getline(infile, line)) {
cout << line << endl;
}
infile.close();
}
void update_Financial_Reports(const string& report) {
ofstream outfile("financial_reports.txt", ios::app);
if (outfile.is_open()) {
outfile << report << endl;
outfile.close();
cout << "Financial report updated.\n";
} else {
cout << "Unable to open file.\n";
}
}

Admin* operator*() {
return this;
}

void setName(const string& name) { this->name = name; }


void setContactInfo(const string& contact) { this->contactInfo = contact; }
void setPassword(const string& pass) { this->password = pass; }
void setUsername(const string& username) { this->username = username; }
string getName() const { return name; }
string getContactInfo() const { return contactInfo; }
};

class Crew : public Employee {


private:
int crewID; // Define crewID variable
string certification; // Define certification variable
string licenseNumber; // Define licenseNumber variable
double hoursWorked; // Define hoursWorked variable
bool availability; // Define availability variable
string scheduleFile; // Define scheduleFile variable
public:
Crew(const string& nu, const string& pass, const string& name, const string&
ci, int id, const string& cert, const string& li, const string& sf, double wh)
: Employee(nu, pass, name, ci), crewID(id), certification(cert),
licenseNumber(li), scheduleFile(sf), hoursWorked(wh) {}
void login() override {
Employee::login();
if (getRole() == "Crew") {
cout << "Crew member has logged in." << endl;
}
}
void signup() override {
Employee::signup();
cout << "Crew member has signed up." << endl;
}

void assign_crew_to_flight(Schedule& schedule) {


ifstream inFile(schedule.getFilename());
if (inFile.is_open()) {
string flightNumber, departureTime, arrivalTime;
while (inFile >> flightNumber >> departureTime >> arrivalTime) {
if (availability) {
cout << "Crew " << crewID << " assigned to flight: " <<
flightNumber << endl;
availability = false;
break;
}
}
inFile.close();
} else {
cout << "Unable to open schedule file.\n";
}
}
void track_work_hours(double hW) {
cout << "Work hours tracked. Total work hours: " << hW << endl;
}
void display_crew_details() const {
cout << "Crew ID: " << crewID << endl;
cout << "Name: " << getName() << endl;
cout << "Certification: " << certification << endl;
cout << "License Number: " << licenseNumber << endl;
}
void assign_certificate(const string& newCertification) {
certification = newCertification;
cout << "Certificate assigned: " << certification << endl;
update_certificate_file();
}
void update_certificate_file() {
ofstream outFile("certificate_file.txt", ios::app);
if (outFile.is_open()) {
outFile << "Crew ID: " << crewID << endl;
outFile << "Name: " << getName() << endl;
outFile << "Certification: " << certification << endl;
outFile.close();
cout << "Certificate added to file.\n";
} else {
cout << "Unable to open certificate file.\n";
}
}
void update_schedule(const string& newSchedule) {
cout << "Schedule updated: " << newSchedule << endl;
update_crew_schedule(newSchedule);
}
void update_crew_schedule(const string& newSchedule) {
ifstream inFile(scheduleFile);
ofstream outFile("temp_schedule.txt");
if (inFile.is_open() && outFile.is_open()) {
string flightNumber, departureTime, arrivalTime;
while (inFile >> flightNumber >> departureTime >> arrivalTime) {
if (flightNumber == newSchedule) {
outFile << newSchedule << " " << departureTime << " " <<
arrivalTime << "\n";
} else {
outFile << flightNumber << " " << departureTime << " " <<
arrivalTime << "\n";
}
}
inFile.close();
outFile.close();
if (remove(scheduleFile.c_str()) != 0 || rename("temp_schedule.txt",
scheduleFile.c_str()) != 0) {
cout << "Error updating crew schedule.\n";
} else {
cout << "Crew schedule updated.\n";
}
} else {
cout << "Unable to open schedule files.\n";
}
}
bool check_fuel_level(int fuel_level) const {
cout << "Checking fuel level... ";
if (fuel_level >= 100 && fuel_level <= 1000) {
cout << "Fuel level is good. The flight is ready to go." << endl;
return true;
} else {
cout << "Fuel level is not suitable for the flight." << endl;
return false;
}
}
bool check_engine_status(const string& engine_status) const {
cout << "Checking engine status... ";
if (engine_status == "good") {
cout << "The airplane is in good condition for the flight." << endl;
return true;
} else {
cout << "The airplane is not suitable for the flight due to engine
issues." << endl;
return false;
}
}
void notifyPassengerItems(const vector<string>& passengerItems) {
cout << "Passenger has selected the following items: ";
for (const auto& item : passengerItems) {
cout << item << ", ";
}
cout << endl;
}

Crew* operator*() {
return this;
}
// Setters
void setUsername(const string& username) { this->username = username; }
void setCrewID(int id) { crewID = id; }
void setCertificate(const string& c) { certification = c; }
void setLicenseNumber(const string& l) { licenseNumber = l; }
void setWorkedHours(const double& hw) { hoursWorked=hw;}
// Getters
int getCrewID() const { return crewID; }
string getCertification() const { return certification; }
bool getAvailability() const { return availability; }
string getLicenseNumber() const { return licenseNumber; }
};

int main() {
int choice;
string currentUser;
vector<Admin*> admins;
vector<Crew*> crews;

Schedule schedule("filename.txt");
while (true) {
cout << "****Welcome to our Airline System****" << endl;
cout << "1. Login" << endl;
cout << "2. If you are new,please Sign Up" << endl;
cout << "3. Exit" << endl;
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1: {
string role;
cout << "Enter Role (Admin/Crew): ";
cin >> role;
if (role == "Admin") {
string un, name, pass, ci, sd, mt;
int mid, aid;
cout << "Enter Username: ";
cin >> un;
cout << "Enter Password: ";
cin >> pass;
cout << "Enter Name: ";
cin >> name;
cout << "Enter Contact Info: ";
cin >> ci;
Admin* admin = new Admin(mid, aid, sd, mt, un, pass, name, ci);

if (admin->validateLogin(un, pass)) {
admin->login();
admins.push_back(admin);
currentUser = admin->getUsername();
currentUser = role;
} else {
cout << "Invalid username or password." << endl;
delete admin; // Clean up memory
}
break;
}
else if (role == "Crew") {
string nu, cert, name, ci, li, sf, pass;
int id;
double wh;
cout << "Enter Username: ";
cin >> nu;
cout << "Enter role: ";
cin >> role;
cout << "Enter password: ";
cin >> pass;
cout << "Enter name: ";
cin >> name;
cout << "Enter contact: ";
cin >> ci;
cout << "Enter certificate: ";
cin >> cert;
cout << "Enter licence: ";
cin >> li;
cout << "Enter work hours: ";
cin >> wh;
Crew* crew = new Crew(nu, pass, name, ci, id, cert, li, sf,
wh);

if (crew->validateLogin(nu, pass)) {
crew->login();
crews.push_back(crew);
currentUser = crew->getUsername();
currentUser = role;
} else {
cout << "Invalid username or password." << endl;
delete crew; // Clean up memory
}
} else {
cout << "Invalid role!" << endl;
}
break;
}
case 2: {
string role;
cout << "Enter Role (Admin/Crew): ";
cin >> role;
if (role == "Admin") {
string un, name, pass, ci, sd, mt;
int mid, aid;
cout << "Enter Username: ";
cin >> un;
cout << "Enter Password: ";
cin >> pass;
cout << "Enter Name: ";
cin >> name;
cout << "Enter Contact Info: ";
cin >> ci;
Admin* admin = new Admin(mid, aid, sd, mt, un, pass, name, ci);

admin->signup();
admins.push_back(admin);
currentUser = admin->getUsername();
currentUser = role;
} else if (role == "Crew") {
string nu, cert, name, ci, li, sf, pass;
int id;
double wh;
cout << "Enter Username: ";
cin >> nu;
Crew* crew = new Crew(nu, pass, name, ci, id, cert, li, sf,
wh);
crew->signup();
crews.push_back(crew);
currentUser = crew-> getUsername();
currentUser = role;
} else {
cout << "Invalid role!" << endl;
}
break;
}
case 3: {
cout << "Exiting..." << endl;
return 0;
}
default:
cout << "Invalid choice, please try again." << endl;
}
// After successful login or signup
if (currentUser != "") {
cout << "Welcome, " << currentUser << "!" << endl;
// Admin or Crew specific menu based on role
while (true) {
string username, password, name, contactInfo;
cout << "Enter username: ";
cin >> username;
cout << "Enter password: ";
cin >> password;
cout << "Enter name: ";
cin >> name;
cout << "Enter contact info: ";
cin >> contactInfo;
if (currentUser == "Admin") {

// Admin menu
cout << "Admin Menu:" << endl;
cout << "1. Manage Employees" << endl;
cout << "2. View Employee Details" << endl;
cout << "3. View Financial Reports" << endl;
cout << "4. Manage Maintenance" << endl;
cout << "5. Manage Inventory" << endl;
cout << "6. Logout" << endl;
cout << "Enter your choice: ";
cin >> choice;
Admin* admins;
switch (choice) {
case 1: {
cout << "1. Add Employee" << endl;
cout << "2. Remove Employee" << endl;
cout << "3. Update Employee" << endl;
cout << "Enter your choice: ";
cin >> choice;

switch (choice) {
case 1: {
// Create an Employee object using the provided
information
Employee emp(username, password, name, contactInfo);

// Add the Employee to the Admin's list


admins[0].add_Employee(emp);

break;
}

case 2:{
string usernameToRemove;
cout << "Enter username of the employee to remove: ";
cin >> usernameToRemove;
admins[0].remove_Employee(usernameToRemove);
break;
}
case 3:
{
string newUsername,newPassword, newName, newContactInfo;
cout << "Enter username of the employee to update: ";
cin >> newUsername;
cout << "Enter password of the employee to update: ";
cin >> newPassword;
cout << "Enter username of the employee to update: ";
cin >> newName;
cout << "Enter username of the employee to update: ";
cin >> newContactInfo;
Employee updatedEmployee(newUsername, newPassword, newName,
newContactInfo);
admins[0].update_Employee(newUsername, updatedEmployee);
break;
}
default:
cout << "Invalid choice, please try again." <<
endl;
break;
}

case 2: {
(*admins[0])->view_Employee_Details();
break;
}
case 3: {
(*admins[0])->view_Financial_Reports();
break;
}
case 4: {
cout << "Maintenance Menu:" << endl;
cout << "1. Perform Maintenance" << endl;
cout << "2. Handle Maintenance Report" << endl;
cout << "3. Complete Maintenance" << endl;
cout << "4. Update Maintenance Records" << endl;
cout << "Enter your choice: ";
cin >> choice;

switch (choice) {
case 1: {
admins[0].performMaintenance();
break;
}
case 2: {
string newMaintenanceID;
cout << "Enter new maintenance ID: ";
cin >> newMaintenanceID;
admins[0].handleMaintenanceReport(newMaintenanceID);
break;
}
case 3: {
admins[0].completeMaintenance();
break;
}
case 4: {
admins[0].updateMaintenanceRecordsToFile();
break;
}
default:
cout << "Invalid choice, please try again." << endl;
break;
}
break; // Add break here to exit case 4
}

// Inside case 5:
case 5: {
cout << "Inventory Menu:" << endl;
cout << "1. Add Item" << endl;
cout << "2. Remove Item" << endl;
cout << "3. Get Stock Level" << endl;
cout << "4. Get Item Details" << endl;
cout << "Enter your choice: ";
cin >> choice;
string item, loc;
int stock;
bool avail;

switch (choice) {
case 1: {
cout << "Following items are available, please select the one you wish
to add: ";
admins[0].addInventoryItem(item, stock, avail, loc);
break;
}
case 2: {
string itemToRemove;
cout << "Enter item to remove: ";
cin >> itemToRemove;
admins[0].removeInventoryItem(itemToRemove);
break;
}
case 3: {
admins[0].getStockLevel(item);
break;
}
case 4: {
admins[0].getItemDetails(item);
break;
}
default:
cout << "Invalid choice, please try again." << endl;
break;
}
}
}
}
}
else if (currentUser == "Crew") {
// Crew menu
cout << "Crew Menu:" << endl;
cout << "1. Assign Crew to Flight" << endl;
cout << "2. Track Work Hours" << endl;
cout << "3. Display Crew Details" << endl;
cout << "4. Assign Certificate" << endl;
cout << "5. Update Schedule" << endl;
cout << "6. Check Fuel Level" << endl;
cout << "7. Check Engine Status" << endl;
cout << "8. Logout" << endl;
cout << "Enter your choice: ";
cin >> choice;
Crew* crews ;
switch (choice) {
case 1: {
(*crews[0]) ->assign_crew_to_flight(schedule);
break;
}
case 2: {
double hours;
cout<<"Enter your worked hours";
(*crews[0]) ->track_work_hours(hours);
break;
}
case 3:{
(*crews[0]) ->display_crew_details();
break;
}
case 4: {
string certificate;
cout << "Enter certificate: ";
cin >> certificate;
(*crews[0]) ->assign_certificate(certificate);
break;
}
case 5: {
string schedule;
cout << "Enter schedule: ";
cin >> schedule;
(*crews[0]) ->update_schedule(schedule);
break;
}
case 6: {
int fuelLevel;
cout << "Enter fuel level: ";
cin >> fuelLevel;
(*crews[0]) ->check_fuel_level(fuelLevel);
break;
}
case 7: {
string engineStatus;
cout << "Enter engine status: ";
cin >> engineStatus;
(*crews[0]) ->check_engine_status(engineStatus);
break;
}
case 8: {
cout << "Logging out..." << endl;
currentUser = "";
break;
}
default:
cout << "Invalid choice, please try again." << endl;
}
}
if (currentUser == "") {
cout<<"Loggout out "<<endl;
}
}
}
}
for (auto admin : admins) {
delete admin;
}
for (auto crew : crews) {
delete crew;
}
return 0;
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy