10-152-311 - Object-Oriented Programming 1

3.1 Airline Activity: Overview

Wuv Luv Air is growing! WLA now has an airport in Norway. Sigurd, a new traveler, is taking a trip to from Oslo, Norway, to Wausau, WI. Wuv Luv has also acquired a biplane. We need to find the location of that biplane, and calculate the total mileage of each of the airplanes at the airport.

Define the new classes and the list as needed, and create instances of these objects and set their fields. Create the methods in the MainWindow as shown in the diagrams.

3.1 Airline Activity: Class Diagram

Implement the changes specified in the following UML class diagram.

Create any button(s) and button click event handler(s) in the WPF window designer (if specified in the class diagram).

  1. Open the MainWindow's designer by double-clicking on the file MainWindow.xaml (not MainWindow.xaml.cs) in the Solution Explorer.
  2. Navigate to the Toolbox (if hidden, restore it by clicking View | Toolbox).
  3. Expand the Common WPF Controls section of the Toolbox.
  4. Click the Button control in the Toolbox, making it the active control type.
  5. Place a new button on the window by clicking on the background of the window with the Button control selected per "step d" above.
  6. Position the new button immediately beneath and aligned with the left of the existing button(s) (it will snap in place, showing a recommended margin in red).
  7. Stretch the button to be the same width as the previous button(s) (it will snap to the correct width).
  8. Navigate to the Properties Window (if hidden, restore it by clicking View | Properties Window).
  9. Ensure that the Properties Window is in "property mode" (click on its wrench icon)
  10. Ensure that the new button is the currently-focused control.
  11. Enter a Height in the Properties Window (under the Layout section) of 23.
  12. Enter a Name in the Properties Window as specified in the class diagram.
  13. Enter Content in the Properties Window as a friendly version of the name (e.g. "newZooButton" as "New zoo").
  14. Change the Properties Window to "event mode" (click on its lightning bolt icon)
  15. Double-click in the Click event's text box, which will:
    1. Create an event handler for the button.
    2. Navigate to code view. (You can alternately navigate to code view by right-clicking on the designer and selecting "View Code", or by pressing F7).

PNG image of 3.1  Airline UML class diagram
  1. When creating classes be sure to:
    1. Ensure the class in the root namespace. This can be done in one of two ways. Either by adding the class in the project, i.e. scenario, or by adding the class to the business classes folder and removing the ".Business_Classes" designation from the namespace.
    2. insert the following line of code immediately above the class definition:
      [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Encapsulation not yet taught.")]
  2. Open the main window (MainWindow.xaml) in designer mode (right-click and click "View Designer" or press Shift-F7 to go to designer mode).

3.1 Airline Activity: Object Diagram

Instantiate the objects and set their field values as specified in the following UML object diagram.

PNG image of 3.1 Airline UML object diagram

3.1 Airline Activity: Code Snippet

Within the newAirlineButton click event handler use the following code snippet as your guide to writing the code.

// Create an instance of the Airline

// Set field values of Wuv Luv Air.

// Set a temporary variable for an airplane.

// Create an instance of the airplane (Biplane)

// Set the field values of the Biplane.

// Add the Biplane to the airlines list of airplanes.

// Create a new instance of an airplane (Personal Jet)

// Set the field values of the Personal Jet

// Add the Personal Jet to the airlines list of airplanes

// Create a temporary variable for an airport

// Create an instance of the airport (Wausau Airport)

// Set the field values of the Wausau airport.

// Add the Wausau airport to the airlines list of airports.

// Create a new instance of an airport (Oslo Airport)

// Set the field values of the Oslo airport

// Add the Oslo airport to the airlines list of airports.

// Create a temporary variable for a traveler.

// Create an instance of the traveler (Vladimir)

// Set the field values of Vladimir

// Set the field values of Vladimir's carry on bag

// Set the field values of Vladimirs's checked bag.

// Set the field values of Vladimir's ticket.

// Add Vladimir to the airline's list of customers

// Create a new instance of a traveler.

// Set the field values of the traveler. (Sigurd)

// Set the field values of Sigurd's carry on bag

// Set the field values of Sigurd's checked bag

// Set the field values of Sigurd's ticket.

// Add Sigurd to the airlines list of customers

// Create a temporary variable for a pilot

// Create an instance of a pilot (Biggs)

// Set the field values of Biggs

// Add Biggs to the airlines list of pilots

// Set the field values of the CurrentFlier.

// Set the field values of the captain.

// Set the field values of customer.

// Set the field values of carry on bag.

// Set the field values of checked bag.

// Set the field values of the Current ticket.

// Set the field values of Wausau Airport

3.1 Airline Activity: Final Steps

On the two additional buttons, write code to perform the following:

Test, Complete and Submit

  1. Build your program - Eliminate compiler errors and warnings
  2. Debug/Test your program - Set breakpoints, step through code, monitor values
  3. Make your code StyleCop-compliant
  4. Close your Visual Studio solution.
  5. Compress your Visual Studio solution to a zip file.
  6. Submit the zip file via Blackboard.

Grading Rubric

PNG image of the 3.1 Airline rubric