CIS 636 Spring 2004 Assignment 3 – Object Oriented Programming in Java – Inheritance 100 points
Assigned: 02/12/2004
Due: 02/19/2004 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:
We are building more pieces of a simplified EzPass toll
collection program. The next pieces to add include EzPassBridge, and
EzPassInterchange which are child classes of EzPassLocation created in
Assignment 2. An EzPassBridge should be
able to keep track of the price for going over the bridge (assume only one
category of customer to keep things simple – no trucks). It should provide a
variety of constructors, allowing users a variety of ways to create an EzPass
Location. These should include
providing the client program the ability to specify info related to the
Location - - including the name, city, state, etc). It should provide all
necessary accessors – inspectors and mutators, so that data can all be declared
as private. Mutators should protect against bad data getting into objects (e.g.
bad toll price – nothing should be less than $0.50, nor more than $10.00
(Chesapeake Bay Bridge Tunnel)). The
class should support versions of equals and toString appropriate to the class.
An EzPassInterchange should be able to keep track of or
calculate the price for exiting at the interchange after entering at any
interchange within the same state (leaving one state and entering another
represent an exit then an entrance).
This may mean having an array or other data structure keeping track of
starting interchange and price for each possible starting interchange (assume
only one category of customer to keep things simple – no trucks). For right now, many of you may find the
easiest way to handle this is parallel arrays – an array of starting
interchanges and an array of prices that are kept in synch (if you are finding
this all really easy so far, you could look up a data structure designed for
lookups, such as HashMaps). The class should provide a variety of constructors,
allowing users a variety of ways to create an EzPass Location. These should include providing the client
program the ability to specify info related to the Location - - including the
name, city, state, etc). There may not be any simple accessors to provide, but
significant capabilities are needed: a)
Lookup a toll, given a starting interchange; and b) include an additional toll
listing, given a starting interchange and a price – important for getting
started (make sure the price is valid – let’s say that interchange to
interchange tolls can be anywhere from $0.10 to $25). Additional desirable capabilities such as deleting a toll
listing, changing a toll price, increasing the toll price by a given
percentage, etc should probably be left for another day. The class should support versions of equals
and toString appropriate to the class (don’t try to show a whole interchange as
part of a price list, it will recurse forever; likewise equals might should
skip testing to see if the price lists are the same.
You are to build the classes described above, and also write
main program(s) (probably part of the same classes) that will test out the
capabilities of the classes (thoroughly).
You will need to create several interchanges to test out that class; you
can hack those up in code instead of asking the user for a bunch of information
as part of setup. If you do do any input, I encourage you to keep using my
RedmondMsgInBasic. Cancels on input dialog boxes will not be fully handled
unless you use “robust versions” (which will require that you also download
exception files).
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:
·
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 class methods work.
·
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. 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.