120 likes | 310 Views
ENEE150 Recitation 7. Outline. Project 2 Structures. Announcements. Project 1 grades should be coming out this weekend. Project 2: ENEE Airplanes Flight Database. Parse input files, print menu, prompt user Three input files – use file I/O Airports.txt Routes.txt Flights.txt
E N D
Outline • Project 2 • Structures
Announcements • Project 1 grades should be coming out this weekend
Project 2: ENEE Airplanes Flight Database • Parse input files, print menu, prompt user • Three input files – use file I/O • Airports.txt • Routes.txt • Flights.txt • intargc, char *argv[] • If files cannot be opened, print error message
Menu • Print for user input • User must enter a number: 1 – 4 • If the number is not 1 – 4, print error message
Airports.txt • Contains 3-letter airport code and location • Format • 3-letter airport code • Two whitespaces • Airport location • ‘\n’ character at end of line • Example: BQN Aquadilla, Puerto Rico • Notice there are spaces within the string • May want to use ‘\n’ to recognize end of string
Routes.txt • Shows the non-stop flights • Format • Unique route ID (integer) • ‘.’ character • Two whitespaces • Departure airport code • Whitespace • Arrival airport code • Alphabetical order (by city) of the departure and then alphabetical order of arrival
Flights.txt • Format • Unique flight number (integer) • Route ID/number • Departure time • 12 hour format • ‘a’ for am and ‘p’ for pm • Arrival time • Repeat • ‘Daily’ • Numbers • Numbers are the days that the flight runs • ie. 23 which would represent Monday and Tuesday • Xnumber • Numbers after ‘X’ represent days that the flight doesn’t run • ie. X7 which is NOT Saturday
Menu Options • Option 1 – Print flights • Enter flight number • If flight doesn’t exist, print error message • Option 2 – Print airports • Enter 3-letter airport code • If flight doesn’t exist, print error message • Option 3 – Nonstop flights • Prompt for two airport codes • Prompt for days (0 means any day) • Option 4 – 1-stop flights • Same prompt and error conditions as option 3
Important Notes • There will never be more than • 100 airports in airports.txt • 500 routes in routes.txt • 3000 flights in flights.txt • 2000 characters per line • 100 characters per string • String.h is allowed (strcmp?) • fgets • Structures are allowed
Checking Your Project • Get output files from website • Transfer them to GLUE • Generate your output • a.out< test1.in > ! output.txt • diff test1.out output.txt • Newline characters at the end of the file are ok
Structures • Group different types together • Usually use typedef • Pass by value (as oppose to pass by reference) • struct.c