// Option 1 (Standard): Cruise Ship Manifest. // Uses linked lists, merge sort, quick sort, and binary search // to manage guest and employee manifests from random_names.txt. #pragma once #ifndef OPTION1_H #define OPTION1_H #include "TLinkedList.h" #include "TPerson.h" // Global lists and counters used across the assignment: // - 'e' stores EMPLOYEE records // - 'g' stores GUEST records // - guestCount / employCount track how many were loaded inline TLinkedList g, e; inline int guestCount = 0; inline int employCount = 0; int RunApp(); inline void printline() { std::cout << "----------------------------------------" << std::endl; } inline void pack(const std::string& line) { std::cout << "\n\n\n" << std::endl; printline(); std::cout << line << std::endl; printline(); std::cout << "\n\n\n" << std::endl; } /** * @brief Callback function to process one name. static bool NameReadCallback(const int aIndex, const int aTotalCount, const std::string& aFirstName, const std::string& aLastName) { std::cout << "Reading Name " << (aIndex + 1) << " of " << aTotalCount << ": " << aFirstName << " " << aLastName << "\n"; // We only want to read 10 names (index 0 through 9) // Return false when aIndex is 9 to stop the loop after this one. return (aIndex < 9); } */ // Callback used by readNamesFromFile. // - Creates a TPerson with status (EMPLOYEE or GUEST) // - First 1500 entries are EMPLOYEE, the rest are GUEST // - Appends each person to the appropriate linked list and updates counters static bool onNameRead(const int aIndex, const int aTotalCount, const std::string& aFirstName, const std::string& aLastName) { // Determine status based on index: first 1500 are employees, rest are guests. const ENumStatus status = (aIndex < 1500) ? EMPLOYEE : GUEST; const TPerson p(aFirstName, aLastName, status); if (status == EMPLOYEE) { e.Append(p); employCount++; } else { g.Append(p); guestCount++; } std::cout << "[" <= 0 && (targetArray[left]->firstName == target || targetArray[left]->lastName == target)) { --left; } // Move right while neighbouring entries share the same first or last name while (right < arraySize && (targetArray[right]->firstName == target || targetArray[right]->lastName == target)) { ++right; } for (int i = left + 1; i < right; ++i) { std::cout << "Match found: \nName: " << targetArray[i]->firstName << " " << targetArray[i]->lastName << " | status: " << (targetArray[i]->status == 0 ? "Guest" : "Employee") << " | cabinsize: " << targetArray[i]->cabinSize << "\n" << std::endl; } } #endif // OPTION1_H