programming assignment 05 blue jet flight information with class and inheritance general and...

15
Programming Assignment 05 Blue Jet Flight Information with Class and Inheritance General and specific program requirements: 1. Problem: Blue Jet has just established flights to three cities from Sacramento. Blue Jet wants you to design and program a system to display flight information. (Yes, I know the real name is jetBlue.) 2. Your GUI must look like the one below. 3. Get a picture of any Blue Jet plane by searching Google using Image and the key words “jetBlue” 4. You are to create a Class with the Class Name, Properties and Method shown in the diagram below. The class “clsFlightInformation” must be in a separate file within your solution. clsFlightInform ation D estination ArrivalTim e DepartureTim e Gate TicketPrice Class Name Properties Method 5. You are to use a ComboBox to select the destination city. 6. Place the word Destination in the Text property of the ComboBox as seen. ComboBoxes are covered in Chapter 5 (Gaddis) Due Dec 4, 2014 Get started now.

Upload: britton-wilkerson

Post on 02-Jan-2016

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Programming Assignment 05 Blue Jet Flight Information with Class and Inheritance General and specific program requirements: 1. Problem: Blue Jet has just

Programming Assignment 05Blue Jet Flight Information with Class and Inheritance

General and specific program requirements: 1. Problem: Blue Jet has just established flights to three cities from Sacramento. Blue Jet wants you to design and

program a system to display flight information. (Yes, I know the real name is jetBlue.)2. Your GUI must look like the one below.3. Get a picture of any Blue Jet plane by searching Google using Image and the key words “jetBlue”4. You are to create a Class with the Class Name, Properties and Method shown in the diagram below.

The class “clsFlightInformation” must be in a separate file within your solution.

clsFlightInformation

DestinationArrivalTimeDepartureTimeGate

TicketPrice

Class Name

Properties

Method

5. You are to use a ComboBox to select the destination city.6. Place the word Destination in the Text property of the

ComboBox as seen.

ComboBoxes are covered in Chapter 5 (Gaddis)

Due Dec 4, 2014Get started now.

Page 2: Programming Assignment 05 Blue Jet Flight Information with Class and Inheritance General and specific program requirements: 1. Problem: Blue Jet has just

Programming Assignment 05Blue Jet Flight Information with Class

General and specific program requirements: 7. Place the three city-state items in the ComboBox as shown below.

See the next slides for the directions.

Page 3: Programming Assignment 05 Blue Jet Flight Information with Class and Inheritance General and specific program requirements: 1. Problem: Blue Jet has just

Programming Assignment 05Blue Jet Flight Information with Class

General and specific program requirements: 8. Select the ComboBox and Click on the Items’ (Collections) property button.

Select

Click here.

Page 4: Programming Assignment 05 Blue Jet Flight Information with Class and Inheritance General and specific program requirements: 1. Problem: Blue Jet has just

Programming Assignment 05Blue Jet Flight Information with Class

General and specific program requirements: 9. Enter the City-State values into the “String Collections Editor” EXACTLY as shown. There is one space after the

comma. 10. Click OK (The ComboBox is now loaded and ready to use.)

Enter these items here.

Click OK when done.

Page 5: Programming Assignment 05 Blue Jet Flight Information with Class and Inheritance General and specific program requirements: 1. Problem: Blue Jet has just

The arrows show direction of the flow of data between the Object and Form1’s code.

objFlightInformation

DestinationArrivalTimeDepartureTimeGate

TicketPrice

Programming Assignment 05Blue Jet Flight Information with Class

General and specific program requirements: 11. You are to code the class and then use its object in Form1’s code.12. The object and Form1’s GUI communicate as shown below:

a. The City-State from Form1’s GUI Sets the Destination Property in the Object.b. The Form1 GUI then Gets these three Properties values from the object: ArrivalTime, DepartureTime, and Gate.c. The TicketPrice Method calculates TicketPrice by adding 15% (Tax) to the Flight Price. That Method is used by

Form1’s GUI, but the calculations are done within the TicketPrice Method within the Object.12.5 You must use Option Strict On in the Form1 code, and in both classes.

Form1 code

Object Code

Page 6: Programming Assignment 05 Blue Jet Flight Information with Class and Inheritance General and specific program requirements: 1. Problem: Blue Jet has just

Programming Assignment 05Blue Jet Flight Information with Class

General and specific program requirements: 13. You MUST use the values below for each of the three City-State Items.

Washington, DC Vancouver, WA Chicago, ILPrice 300D Price 100D Price 200DTax Rate 0.15D Tax Rate 0.15D Tax Rate 0.15DDeparture Time 7:00 am Departure Time 8:00 am Departure Time 9:00 amArrival Time 3:00 pm Arrival Time 10:00 am Arrival Time 2:00 pmGate 10 Gate 20 Gate 30

14. The partial code below is how I programmed the class. This will serve as a template. YOU MUST DOCUMENT THIS CODE, AS YOU WOULD THE CODE ON FORM1. I DID NOT DOCUMENT IN ORDER TO SAVE SPACE.

Public Class clsFlightInformation Private mstrDestination As String Private mstrDepartureTime As String Private mstrArrivalTime As String Private mstrGate As String Private Const mdecWASHINGTON_DC_PRICE As Decimal = 300D Private Const mdecVANCOUVER_WA_PRICE As Decimal = 100D Private Const mdecCHICAGO_IL_PRICE As Decimal = 200D Private Const mdecTAX_RATE As Decimal = 0.15D Public WriteOnly Property Destination() As String Set(ByVal Value As String) mstrDestination = Value I USED IF-THEN-ELSE CASE LOGIC HERE. THIS IS WHERE I SET THE VALUES OF mstrDestination, mstrDepartureTime, mstrArrivalTime, and mstrGate. End Set End Property Public ReadOnly Property DepartureTime() As String Get Return I HAD CODE HERE. End Get End Property Public ReadOnly Property ArrivalTime() As String Get Return I HAD CODE HERE. End Get End Property Public ReadOnly Property Gate() As String Get Return I HADE CODE HERE. End Get End Property Public Function TicketPrice() As String I USED IF-THEN-ELSE CASE LOGIC HERE. USE THE CONSTANTS ABOVE TO CALCULATE THE TicketPrice. Use FormatCurrency() function here and return the value as a string so that it can be assigned, without conversion, to a label text property in the Form Code. End FunctionEnd Class

Page 7: Programming Assignment 05 Blue Jet Flight Information with Class and Inheritance General and specific program requirements: 1. Problem: Blue Jet has just

Programming Assignment 05Blue Jet Flight Information with Class

General and specific program requirements: 15. Now that you have coded your class, Sacramento International Airport decided to temporarily add a $10 gate fee.

Since you don’t want to rewrite your base class, you are to write another class which will add $10 to the ticket price of each flight. You must use inheritance for this. Below is a diagram of how this will function.

16. IMPORTANT: I think it best to get your program running without using inheritance, then add it as a last step. You will need to make minor modifications to the Form1 code when you add a derived class.

17. Both classes MUST be written as two separate files within the solution. You will get a ZERO grade if you code the classes within the code of the Form. Again, the Classes below, must be written as two separate files.

18. The method in the derived class only needs one line of code within it.

clsFlightInformation

DestinationArrivalTimeDepartureTimeGate

TicketPrice

clsRevisedFlightInformation

RevisedTicketPrice

clsRevisedFlightInformatiion will inherit the four properties and the single method from clsFlightInformation. Note that there are no properties and only one method in clsRevisedFlightInformation.

Your Form1 code must now use clsRevisedFlightInformation and not clsFlightInformation; and there is no need to change objFlightInfomation to objRevisedFlightInformation unless you want to. Remember, this $10 gate fee is temporary.

Base class

Derived class

IMPORTANT: GET THE PROGRAM RUNNING WITHOUT clsRevisedFlightInformation, THEN ADD IT.IMPORTANT: GET THE PROGRAM RUNNING WITHOUT clsRevisedFlightInformation, THEN ADD IT.

No Properties

One Method

Page 8: Programming Assignment 05 Blue Jet Flight Information with Class and Inheritance General and specific program requirements: 1. Problem: Blue Jet has just

Additional Requirements for Program05PROGRAM REQUIREMENTS:1. Use good internal documentation in Form1 code and the Class code. See example on the later slides.

Don't forget to use single-line comments within the program code, IF they add to comprehensionof how the program functions.

2. Be sure to use the FormatCurrency function to display the ticket price. In this program, use it in the Class. In other words the ticket price will be sent back to the Form code all ready to be displayed in a label.

3. You must use Option Strict On in the Form1 code and the two classes4. You must use the appropriate three-letter prefixes for variables and constants. If a variable or constant is

declared at the module level, you must add an "m" to the beginning of the three-letter prefix.Example: mstrDepartureTime. See the example on the previous slide.A variable declared WITHIN a subroutine (sub-procedure) does not need the "m" and it must not be used.

5. All variable names must use the "Pascal" method; That is, begin every word in the variable name witha capital letter. All other letters are lowercase. Example: mstrDepartureTime (The prefix must be in lower case.)

6. Constant names must be in all caps. Separate each word with an underscore, and use the appropriateprefixes. Example: mdecVANCOUVER_WA_PRICE Use good identifiers (constant names and variable names.) These must be as meaningful as possible, as short as possible, and as meaningful as possible.

7. There is no need to validate data in this program. 8. Your user interface must look very similar to the one on the first slide.9. Use pseudocode to design the program. That is, write down each step necessary to solve the programming

problem. The steps must be in the appropriate order. Don't worry about the syntax of the code. You willwrite the code later to match the steps you have written down.Remember, never start coding until you know the steps necessary to solve the programming problem.You must fully understand the requirements of the program before you start coding.

10. Always use a "D" after a literal numeric constant which is used to calculate money values.Example: Private Const mdecCHICAGO_IL_PRICE As Decimal = 200D

11. Be sure that you use internal documentation within your class as well as the code on the form.12. The class must use WriteOnly and ReadOnly for properties if appropriate.13. Calculations of the TicketPrice with currency formatting must be done in the Class Method, not in Form1 code.14. All procedures and methods MUST do a SINGLE FUNCTION. Use the “and” & “or” test.14.5 You must use Region/End Region on Form1 code, and both classes. Use Regions on Variable/Constant section, each

property procedure, and each method.

Page 9: Programming Assignment 05 Blue Jet Flight Information with Class and Inheritance General and specific program requirements: 1. Problem: Blue Jet has just

Additional Requirements for Program05 (Continued)PROGRAM REQUIREMENTS:15. The Classes MUST be written as separate files within the solution. You will get a ZERO grade if you code the classes

within the code of the Form. Again, the Classes must be written as separate files.

16. You are to design this program yourself. Do your best to modularize it.

Page 10: Programming Assignment 05 Blue Jet Flight Information with Class and Inheritance General and specific program requirements: 1. Problem: Blue Jet has just

DOCUMENTATION EXAMPLE ONLYYOU MUST FOLLOW THE DOCUMENTATION CHARACTERISTICS OF THE PROGRAMS ON THE NEXT FOUR SLIDES.

DOCUMENTATION EXAMPLE ONLY

DOCUMENTATION EXAMPLE ONLY

Page 11: Programming Assignment 05 Blue Jet Flight Information with Class and Inheritance General and specific program requirements: 1. Problem: Blue Jet has just

DOCUMENTATION EXAMPLE ONLY

DOCUMENTATION EXAMPLE ONLY

DOCUMENTATION EXAMPLE ONLY

Page 12: Programming Assignment 05 Blue Jet Flight Information with Class and Inheritance General and specific program requirements: 1. Problem: Blue Jet has just

DOCUMENTATION EXAMPLE ONLY

DOCUMENTATION EXAMPLE ONLY

DOCUMENTATION EXAMPLE ONLY

Page 13: Programming Assignment 05 Blue Jet Flight Information with Class and Inheritance General and specific program requirements: 1. Problem: Blue Jet has just

************************************************************************************************************************************* 'Program Name: Video Sales Calculator 'Version: 1.00 'Programmer/s: Dr. David Scanlan 'Date: August 15, 2010 'Purpose: Calculates the total amount due for each customer renting videos. ' Validates all input data. '************************************************************************************************************************************* Option Strict On Public Class frmVideo Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " 'DECLARATION SECTION '*********************************************************************************************************************************** ' -- Declares Variables at the module level. ' -- Declares Constants at the module level. '*********************************************************************************************************************************** Dim mdecItemAmount As Decimal Dim mdecTotalAmountDue As Decimal Const mdecDISCOUNT As Decimal = 0.1D Const mdecNEW_DVD_CHARGE As Decimal = 4D Const mdecNEW_VHS_CHARGE As Decimal = 3.5D Const mdecDVD_CHARGE As Decimal = 3.5D Const mdecVHS_CHARGE As Decimal = 3D 'CALCULATES AMOUNT DUE '*********************************************************************************************************************************** ' -- Calculates amount due for all rentals. ' -- Validates input data. '*********************************************************************************************************************************** Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click 'Calculate the amount due for rentals. End Sub

Below is an example of how documentation must be done.Don't forget to add comments in the code where appropriate.Don't forget to document all button subroutines (sub-procedures).

DOCUMENTATION EXAMPLE ONLY

DOCUMENTATION EXAMPLE ONLY

DOCUMENTATION EXAMPLE ONLY

Page 14: Programming Assignment 05 Blue Jet Flight Information with Class and Inheritance General and specific program requirements: 1. Problem: Blue Jet has just

(Print) Last ____________________________ First_________________

FOLD HERE-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

MIS 15 section: NoonProgram number 1 2 3 4 5 6 7

GRADING STANDARDS POINTS

POINTSDocumentation was done according to guidelines: (0 OR 1 point)

__________GUI is reasonably correct: (0 OR 1 point)

__________ Followed rules for forming constant names & variable names: (0 OR 1 point)

__________Used Option Strict On in the Form code and the two class: (0 OR 1 point)

__________Use FormatCurrency for displaying Ticket Price. (0 OR 1 point)

__________Ticket price is correct for all cities.

(be sure to add tax (.15) and gate charge ($10)) (0 OR 20 points) __________SET and GET used correctly for properties. (0 OR 10 points) __________Correctly used inheritance in the derived class

that added the gate charge. (0 OR 10 points) __________Regions were used on all modulesincluding the two classes. (0 OR 5 points)

__________

ANY CALCULATIONS DONE IN THE FORM CODE (-50 POINTS) (All calculations MUST be done in the classes.)The base and derived classes not in two files in project files. (-50 POINTS)

TOTAL POINTS: 50 pts. possible __________

Form-A Form-AProgramming Assignment 05Blue Jet

Comments:

Page 15: Programming Assignment 05 Blue Jet Flight Information with Class and Inheritance General and specific program requirements: 1. Problem: Blue Jet has just

Program #2 Fall 2011

15

Form-B Form-B

STUDENT FILLS IN THESE BLANKS:

LAST NAME:_______________________________

FIRST NAME:________________________

PROGRAM (Circle) 1 2 3 4 5 6 7 8DATE DUE:_________________DATE SUBMITTED:__________________

PLACE A CHECK NEXT TO THE FOLLOWING:

1. ____ Saved the Program on a CD using the following directory andsub-directory: Your Name\Program 05

2. ____ Printed your full name and program number on the CD using a

permanent black marker.3. ____ Submitted the CD in required envelope style not much larger

than the CD.4. ____ Placed the CD in the envelope.5. ____ Cut out this form along dotted edges and TAPE it to the

envelope.

CUT OUT THIS FORM ALONG THE DOTTED EDGES AND TAPE IT TO THE ENVELOPE.

YOU MUST USE THIS STYLE THAT IS ABOUTTHE SIZE OF YOUR CD.Do not lick to seal. Usemetal clip.

Program 5Blue Jet Program