CIS 636 Spring 2005         Assignment 3 – Object Oriented Programming in Java – Using an Existing Class             100 points

Assigned: 01/31/2006

Due: 02/07/2006 at the start of class 

You may work individually or in pairs for this assignment. But all work must be the work of the person/people whose name is on the code! If working in pairs, the individual contributions should be relatively equal. One possibility is to work together tonight, then finish separately (to avoid communication difficulties).

 

Main Assignment:

America East Airline has decided that they’d like you to help out with running their business.  For this assignment, we are mostly worrying about frequent flyer mileage, and may make a lot of simplifying asumptions. You have been provided a simplified passenger (customer) class that will allow keeping track of the state for a given passenger – including an ID,  name and address information, and frequent flyer information. The passenger class provides behavior allowing – (besides normal constructors, inspectors, and mutators)  controlled access for reducing miles as appropriate for first class upgrades, short trips, cross country trips, and international trips, and for adding a specific number of miles or miles appropriate for a flight flown.  It also provides a toString  and a toShortString method to enable quickly seeing the current state of the passenger (Use this!). 

                You have also been provided with Airport and Route classes to keep track of airports and route from airport to airport (including the distance between them), and collection classes, CollectAirports and CollectRoutes to keep track of groups of airports  and routes (say, all of them). Also, a file handling package is provided so some inputs can come from a file without you having to know much about files.

You will provide another class with a main method that will use the given classes to create a Passenger and fly them around, accumulating frequent flyer mileage  (for simplification we are sticking to only having one passenger for now). This main should give the user the option of keeping flying or quitting.   

 I would like your interaction with the user to be via dialog boxes, using static methods from RedmondMsgInBasic and RedmondMsgOut. See the sample interaction below for a textual replay of what happened in one example.  

Hand in:

To avoid needless long waits, I recommend working on this on the c: drive, then upon completion, copying it to the a: drive, testing it there, and creating an extra backup for yourself.

Miscellaneous:

·         I intend to provide the classes I am providing on a CD if all goes as plans. You will probably need to copy elsewhere in order to do as much as compile this code. It will also be provided on the assignment page of my WWW site, along with documentation (however, note that project and package structures would have to be correctly created to use these). My code is written with package statements;  if you use different packages, change the package statements. You should be able to use the same IO package you created for assignment 2. If you need to obtain it again, you can get any of my IO code you need from the assignment or review page of my WWW site.  It is written with a package statement that assumes that it is in a package of named IO.  If you use a different package, change the package statement.

·         You shouldn’t have to change anything in the my classes (unless you are adding extra capability to your program). If you think you need to, ask me.

·         You shouldn’t have to change anything in RedmondMsgInBasic and RedmondMsgOut. The recommended methods make some simplifying assumptions, since we haven’t covered exception handling yet. This means that some exceptions will result if the user tries hard enough. Until we cover exceptions, we won’t catch invalid values that are the wrong type (e.g. letters where numbers are needed)).  No biggie at this point.

·         In using the readValidInt etc methods in RedmondMsgInBasic, you automatically get validation.  However, strings are difficult to validate. The provided mutators (set…) do some checking when possible (e.g. checking that a state is two characters long).  In your code, use these capabilities to ensure we don’t end up with bad passenger info (as seen in the sample interaction below).

·         Read the documentation for my classes. Frequently on assignments like this I see some people doing a lot of re-inventing the wheel.  A lot of what needs to be done can be done with provided code.

·         MAKE SURE YOUR PROGRAM WORKS! (i.e. more than just removing compile errors). Try more than the below example; convince yourself that it works.  Be a skeptic. 

·         Put YOUR NAME, and e-mail address and date in comments at the beginning of the program.

·         Also, comment any significant code to document it (each method, each loop, each if, and each significant calculation should have a comment). 

·         Indent code following standard conventions (indent to show that something is “inside” or “part of” the preceding code (e.g. inside if’s or loops, or statements continued on a new line).  The IDE should handle this if you hit ENTER and move on to the next line (If you make changes, you may need to TAB to make things right).

·         Name your variables meaningfully, to describe their use in the program.

Textual Version of Sample Interaction:

Please enter the passenger's last name

Redmond

Please enter the passenger's first name

Mike

Please enter the passenger's city

Philadelphia

Please enter the passenger's street address

1900 W Olney Ave

Please enter the passenger's state

Penn

Please re-enter - Please enter the passenger's state

PA

Please enter the passenger's zip code

191411

Please re-enter - Please enter the passenger's zip code

19141

Please enter the passenger's frequent flyer type (none, regular, preferred, premium)

other

Please re-enter - Please enter the passenger's frequent flyer type (none, regular, preferred, premium)

regular

Please enter the passenger's home airport (3 letter code)

PHI

Airport PHI not found. Please enter the passenger's home airport (3 letter code)

PHL

Passenger working with: ID: 89526 Name: Mike Redmond Addr: 1900 W Olney Ave Philadelphia, PA 19141 Airport: PHL City: Philadelphia State: PA Freq Flyer Type: regular Miles Earned: 0

Now fly around the country and see how many frequent flyer miles you earn:

Please enter the starting airport (3 letter code)

ALB

Please enter the destination airport (3 letter code)

PHL

Passenger Status: ID: 89526 Name: Mike Redmond Freq Flyer Type: regular Miles Earned: 230

Do you want to continue?

y

Please enter the starting airport (3 letter code)

MRZ

Airport MRZ not found. Please enter the starting airport (3 letter code)

ABQ

Please enter the destination airport (3 letter code)

PHZ

Airport PHZ not found. Please enter the destination airport (3 letter code)

PHL

Passenger Status: ID: 89526 Name: Mike Redmond Freq Flyer Type: regular Miles Earned: 2170

Do you want to continue?

y

Please enter the starting airport (3 letter code)

PHL

Please enter the destination airport (3 letter code)

SEA

Route from PHL to SEA not found.

Passenger Status: ID: 89526 Name: Mike Redmond Freq Flyer Type: regular Miles Earned: 2170

Do you want to continue?

y

Please enter the starting airport (3 letter code)

AMA

Please enter the destination airport (3 letter code)

BWI

Passenger Status: ID: 89526 Name: Mike Redmond Freq Flyer Type: regular Miles Earned: 3790

Do you want to continue?

n