diff --git a/display.c b/display.c index 584a47f..731cfd8 100644 --- a/display.c +++ b/display.c @@ -124,10 +124,10 @@ void displaySingleFlightData(FlightDatabase *fdatab, char const *str) { if (strcmp(adding, "more data") == 0) { double avgMile = calculateAverageMilesPerFlight(flight->totalMiles, flight->totalTrips); char *fTime = calculateFlightTime(flight->departTime, flight->arrivalTime); - double earnings = calculateTotalRevenue(flight->seats, 409.99) - printf("\nThis plane's average miles per trip: %.2f miles\n", avgMile); - printf("Total Travel Duration is %s\n", fTime); - printf("Total Expected Earnings: %f\n", earnings); + double earnings = calculateTotalRevenue(flight->seats, 409.99); + printf("\nThis plane's average miles per trip --> %.2f miles\n", avgMile); + printf("Total Travel Duration --> %s\n", fTime); + printf("Total Expected Earnings --> $%.2f\n", earnings); free(fTime); } break; diff --git a/display.h b/display.h index e25ae76..aea961f 100644 --- a/display.h +++ b/display.h @@ -23,7 +23,7 @@ void displaySingleFlightData(FlightDatabase *fdatab, char const *str); Display all available airports in the current flight database @param fdatab the database to check */ -void displayAllAirports(FlightDatabase *fdatab) +void displayAllAirports(FlightDatabase *fdatab); void displayApp(); #endif diff --git a/display.o b/display.o index 1f34007..25a0a2f 100644 Binary files a/display.o and b/display.o differ diff --git a/flights.c b/flights.c index b28c3aa..b577db1 100644 --- a/flights.c +++ b/flights.c @@ -45,7 +45,6 @@ void freeFlightDatabase(FlightDatabase *flightdb) { * @param table the HashTable to free. */ void freeHashTable(HashTable *table) { - // Free the allocated memory for (int i = 0; i < table->size; i++) { CountryNode *countryNode = table->buckets[i]; while (countryNode != NULL) { @@ -140,7 +139,7 @@ void insertAirport(HashTable *table, const char *country, const char *airport) { } AirportNode *current = countryNode->airports; - // Check for duplicate country airports + while (current != NULL) { if (strcmp(current->airport, airport) == 0) { return; diff --git a/flights.o b/flights.o index 33c4d61..53635fc 100644 Binary files a/flights.o and b/flights.o differ diff --git a/main b/main index f6ab9ba..55d9349 100755 Binary files a/main and b/main differ diff --git a/main.c b/main.c index 243c638..4a5916d 100644 --- a/main.c +++ b/main.c @@ -178,9 +178,12 @@ bool isValidDate(const char *date) { @param bookingInfo the struct to store booking information */ void collectData(const char *booking, Booking *bookingInfo) { - printf("\nHello, please Enter your Name: \n\n"); + printf("\nHello, please Enter your First Name: \n\n"); printf("cmd> "); - scanf("%s[^\n]", bookingInfo->name); + scanf("%s[^\n]", bookingInfo->first); + printf("Please Enter your Last Name: \n\n"); + printf("cmd> "); + scanf("%s[^\n]", bookingInfo->last); printf("\nWhich Class Seat would you like? (First, Premium, or Economy) \n\n"); printf("cmd> "); @@ -205,8 +208,8 @@ void collectData(const char *booking, Booking *bookingInfo) { printf("\nAny special requests? (None, Animal, ExtraMeal, ExtraSeat, Vegetarian, Vegan, Veteran): \n\n"); printf("cmd> "); - char * requestInput; - requestInput = readLine(stdin); + char requestInput[12]; + scanf("%s[^\n]", requestInput); toUpperCase(requestInput); if (strcmp(requestInput, "ANIMAL") == 0) { @@ -253,8 +256,7 @@ void bookFlight(FlightDatabase *fdatab) { printf("Oops! This flight was not found in our database. Try again!\n"); } else { collectData(flightID, &bookingInfo); - - printf("\nBooking confirmed for %s on flight %s\n", bookingInfo.name, flightID); + printf("\nBooking confirmed for %s %s on flight %s\n", bookingInfo.first, bookingInfo.last, flightID); printf("Itinerary Number: %s\n", bookingInfo.itineraryNumber); printf("Class: %s\n", (bookingInfo.userClass == FIRST) ? "First" : (bookingInfo.userClass == PREMIUM) ? "Premium" : "Economy"); printf("Date of Birth: %s\n", bookingInfo.dateOfBirth); @@ -268,41 +270,4 @@ void bookFlight(FlightDatabase *fdatab) { ); } -} - -// void collectData(const char * booking) { -// printf("\nHello, please Enter your Name: \n"); -// printf("cmd> "); -// char * read; -// read = readLine(stdin); -// char name[15]; -// attempt: -// if (sscanf(read, "%s[^\n]", name) == 1) { - -// } else { -// free(read); -// print("That was wrong, try again!") -// goto attempt -// } - - -// Class userClass; -// free(read) -// printf("\nWhich Class Seat would you like? (First, Premium, or Economy)"); -// read = readLine(stdin); -// attempt2: -// if (sscanf(read, "%s[^\n]", userClass.toUpper()) == 1) { - -// } else { -// free(read); -// print("That was wrong, try again!") -// goto attempt2 -// } - -// // Generate a random 6 digit itinerary number using the random library starting with #. for example #5ADF32 -// // Also need to collect date of birth -// // Last thing to collect is a special request. This should be another enummeration Dietary restrictions, mobility, and any special service requests (SSRs). -// // SSRs are four-character codes that identify extra services, such as extra seats, meals, or bringing animals on board. you could do ANIMAL, XTRAMEAL, XTRASEAT, VEGETARIAN, VEGAN, VETERAN - - -// } \ No newline at end of file +} \ No newline at end of file diff --git a/main.h b/main.h index cd223b5..ffd4c0c 100644 --- a/main.h +++ b/main.h @@ -25,7 +25,8 @@ typedef enum { } SpecialRequest; typedef struct { - char name[50]; + char first[20]; + char last[20]; Class userClass; char itineraryNumber[7]; char dateOfBirth[11]; diff --git a/main.o b/main.o index f91e401..c9e5183 100644 Binary files a/main.o and b/main.o differ