View the step-by-step solution to:

Question

Create the 'edu.calhoun.python.finalproject.aviation.menu.MenuOptions' module: • Using PyDev in Eclipse, create

the Python package 'edu.calhoun.python.finalproject.menu'. • In the package 'edu.calhoun.python.finalproject.menu', create the Python module MenuOptions. • Edit the MenuOptions module. • Using a from statement make a relative import ('..util') for the all functions created in #3 (i.e. user the asterisk, '*', character) • Create the variable filePath and assign it the value 'aviation/pilots.dat' • Create the function printPilots(pilots). o Using a print statement, display the string value '%5s %-25s %-15s %- 15s' % ('-' *5, '-' * 25, '-' * 15, '-' * 15) o Using a print statement, display the string value '%5s %-25s %-15s %- 15s' % (' # ', ' PILOT TYPE ', ' FIRST NAME ', ' LAST NAME ') o Using a print statement, display the string value '%5s %-25s %-15s %- 15s' % ('-' *5, '-' * 25, '-' * 15, '-' * 15) o Using a for loop iterate through the pilots list using range(len(pilots)) as the limit and the index variable i. ▪ At each iteration use a print statement to display the following string value: '%-5s %-25s %-15s %-15s' % ('(' + str(i + 1) + ')', pilots[i].getClassName(), pilots[i].getFirstName(), pilots[i].getLastName()) • Create the function showPilots(). o Execute an empty print statement (i.e. print()) o Invoke the printPilots() function passing in the return value of invoking the readPilotsFile(filePath)) (NOTE: pass the variable filePath to the readPilotsFile() function) o Using an input statement (no need to assign the user's input), prompt the user the string 'nn'. • Create the function addPilot(). o make an empty string with the variable name pilotType. o Create the variable pilot with the value of None. o Using a while loop with the condition of not pilotType, do the following: ▪ Using a try statement do the following: • Using an input statement, prompt the user the following string and store the value entered by the user into a variable pilotType: o 'nPilot Types:n' '------------n' ' - StudentPilotn' ' - SportPilotn' ' - RecreationalPilotn' ' - PrivatePilotn' ' - FlightInstructorPilotn' ' - AirlineTransportPilotnn' 'Enter a valid pilot type (X to Cancel): ' • Using an if statement, check if the uppercased value in the variable pilotType is equal to the uppercase letter 'X'. o If it is equal, execute a break statement. • Make a new instance of the specific pilot class using the string value in variable pilotType and assign that class instance to the variable pilot: o pilot = globals()[pilotType]() ▪ Using an except statement that tests for a KeyError, do the following: • Using a print statement, display the string value 'n***** INVALID PILOT TYPE! PLEASE TRY AGAIN! *****n' • Using an input statement (no need to assign the user's input), prompt the user the string '' • Assign an empty string to the variable pilotType ▪ Using an else statement, do the following: • Using an input statement, prompt the user the string 'Please enter the pilot's first name: ' and store the string entered by the user into a variable firstName • Using an input statement, prompt the user the string 'Please enter the pilot's last name: ' and store the string entered by the user into a variable lastName • Using the pilot variable with the class instance, invoke the setFirstName function and pass the variable firstName. • Using the pilot variable with the class instance, invoke the setLastName function and pass the variable lastName. • Invoke the readPilotsFile(filePath) and assign the return value to the variable pilots (NOTE: pass the variable filePath to the readPilotsFile() function) • Append the newly created pilot class instance to the pilots list o pilots.append(pilot) • Invoke the writePilotsFile(filePath, pilots) function (NOTE: pass the variable filePath and the pilots list to the writePilotsFile() function) o Using an input statement (no need to assign the user's input), prompt the user the string 'nn'. 

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Let our 24/7 Python Programming tutors help you get unstuck! Ask your first question.
A+ icon
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors