CIS 636 Spring 2006         Assignment 4 – Object Oriented Programming in Java – Creating Classes         100 points

Assigned: 02/07/2006

Due: 02/21/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 would like more help with running their business.  For this assignment, we are mostly worrying about pilots and planes, and may make a lot of simplifying assumptions .The pieces we are starting with are

         a PlaneModel class,

         a Plane class,

         a Person class

         and a subclass of it for a Pilot.

I imagine that we would LATER build classes for flights and tickets and boarding passes etc (if we have enough time), and could re-use what we are creating for other airlines or even FedEx (and in the case of Person, other applications as well).  You are to:

         build the classes,

         and also write (a) main program (s) that will test out the capabilities of the classes (thoroughly).

 

The PlaneModel class should be able to keep track of:

         the name of the model (e.g. 747),

         the manufacturer of the model (e.g. Boeing),

         probably some sort of unique ID,

         and a lot of info related to capacity: number of aisles, number of rows, number of seats in first class, business class, and coach,

         and a “service interval” – the number of miles that can be flown before regular preventative maintenance should be done.

Assume that all of AEA’s planes of a given model have the same configuration (e.g. capacities etc), but don’t build it into the class as a constant – they should be instance variables.

The class should provide constructors,  all necessary accessors – inspectors and mutators, so that data can all be declared as private. Mutators should protect against bad data getting into objects if necessary (e.g. there should not be allowed to have a negative number of seats in first class).  The class should support versions of equals and toString appropriate to the class.

Other behaviors that should be supported –

a)       the ability to find out if the PlaneModel is a real model (to avoid trying to do things to a PlaneModel without useful info in it)

b)       report what the total capacity of the plane is (note that doesn’t have to be stored!!), and

c)       read info about a PlaneModel from a file into a PlaneModel (see Airport and Route for examples).

The Plane class should be able to keep track of

         a unique plane ID,

         the plane model (containing a PlaneModel object),

         the year the plane was purchased,

         the total number of miles it has flown,

         and the number of miles flown since the last preventative maintenance.

The class should provide constructor(s),  any necessary accessors – inspectors and mutators, so that data can all be declared as private.  Mutators should protect against bad data getting into objects if necessary. The class should support versions of equals and toString appropriate to the class.

Additional methods should be provided to

a)       determine if  a given plane is an actual real plane (to avoid trying to do things to a Plane without useful info in it),

b)       report if the plane is due for preventative maintenance (based on the planes miles traveled and the plane model’s service interval,

c)       update the plane’s miles traveled in a controlled way (e.g. update both miles traveled and miles traveled since maintenance based on a based Route),

d)       reset miles since maintenance after maintenance, and

e)       read info about a Plane from a file into a Plane (it is very desirable if the file can contain just the model number (e.g. 747) instead of all info about the model for each time the model is used).    


The Person class should be able to keep track of the

         person’s first and

         last name,

         address (all parts),

         and have some kind of ID.

It should provide constructors,  all necessary accessors – inspectors and mutators, so that data can all be declared as private. The class should support versions of equals and toString appropriate to the class. It would be very desirable if it could “parse” Person info out of a String and return what remains (I might provide code for this; ask?)

 

The Pilot class should be a subclass of Person. So far what I can think of to keep track of would just be the Pilot’s

a)       position (e.g. Captain)

b)       and their hire date. Java has a GregorianCalendar class that can be useful for this. (Date has been mostly “deprecated” (its use is discouraged)). Please ask for help if necessary.

The ability of a user-programmer to set the hire date via their choice of a text string (e.g. 07/04/2006) or three int parameters is very desirable. The class should provide constructors,  all necessary accessors – inspectors and mutators, so that data can all be declared as private. The class should support versions of equals and toString appropriate to the class. It should also be able to

a)       report how many complete years of service the pilot has with AEA (e.g. if they were hired on 06/06/2000, then as of right now they have 5 years of service), and

b)       read info about a Pilot from a file into a Pilot.  

I encourage you to keep using my RedmondMsgInBasic and my RedmondMsgOut class for any needed input and output. Cancels on input dialog boxes will not be fully handled until we cover exceptions.

  

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, creating an extra backup for yourself, then deleting it from the c: drive.

 

Miscellaneous:

·         For testing purposes, you may find it useful to create arrays of objects of the classes you are creating. I will provide some sample files with sample data.

·         I can’t promise you that we will end up finishing this project, because weekly assignments are designed to address specific topics, and the topics needing to be addressed may not fit with what is left to do to create a complete system. However, do your work under the assumption that you will be using it in the future – be robust, document, etc.

·         MAKE SURE YOUR PROGRAM WORKS! (i.e. more than just removing compile errors).  Make your class as robust as possible in preparation for future use.

·         Make sure that your main demonstrates that your methods work.

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

·         Also, comment any significant code to document it (each method, each loop, each if, and each significant calculation should have a comment. In particular, each method needs to have a JAVADOC compatible 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.

·         For now (until we cover exceptions), we won’t catch invalid values that are the wrong type (e.g. letters where numbers are needed). 

·         I believe that the code I gave out on CD last week is still up to date. For this assignment, the only connection may be the ability to pull out the number of miles in a given Route.