Skip to content

Commit

Permalink
[Implement] Booking Security devprnvk
Browse files Browse the repository at this point in the history
  • Loading branch information
devprnvk committed Jun 11, 2024
1 parent e9e22a9 commit 9757756
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 52 deletions.
8 changes: 4 additions & 4 deletions display.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion display.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file modified display.o
Binary file not shown.
3 changes: 1 addition & 2 deletions flights.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
Binary file modified flights.o
Binary file not shown.
Binary file modified main
Binary file not shown.
53 changes: 9 additions & 44 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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> ");
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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


// }
}
3 changes: 2 additions & 1 deletion main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
Binary file modified main.o
Binary file not shown.

0 comments on commit 9757756

Please sign in to comment.