S
SneakyElf
here's the Program i need to write.
i would appreciate any tips on how to go about writing it. and how to
formulate the logic.
thank you
Include constructors for each class, set and get methods as needed in
each subclass. Use this and super whenever possible to simplify the
code.
Write a toString method in each class that prints out the name of the
subclass using the getClass() method of class Object followed by the
instance variables, each preceded by a description.
Create a class named MetroCard that can keep track of its balance and
expiration date. Each MetroCard has a unique serial number.
There are different types of metro cards:
Pay-per ride
Unlimited Ride
Reduced Fare (half fare) for senior citizens or disabled individuals,
stores the owner's name
All metro cards have common characteristics. They should inherit from
a common base class.
Create a class that represents the card reader. It can deduct one fare
from the MetroCard. Consider:
What if there is an unexpired transfer that can be used? (Remember:
transfers are only valid on a different route within a specified
amount of time.)
What if the balance is insufficient?
Plan for rate changes. Should the fare be a literal or a variable?
Create another class that represents the metro card vending machine.
It should have the capacity to create new MetroCards and refill
existing cards.
New cards can have a choice of dollar amounts ($4, $10, $20, etc.).
The amount paid is not necessarily the same as the initial balance of
the MetroCard (i.e., $10 might give you $12).
When refilling an old card, the user can either enter an arbitrary
amount OR choose from a list of dollar amounts. If the user enters a
dollar amount not on the list, the card's balance is increased by the
amount paid. If the user chooses an amount from the list, he might
receive a bonus (as in a new card).
Remember that the rates change periodically. Develop the class in a
way that supports this feature.
This system is not complete yet. Which features can you think of that
we missed?
i would appreciate any tips on how to go about writing it. and how to
formulate the logic.
thank you
Include constructors for each class, set and get methods as needed in
each subclass. Use this and super whenever possible to simplify the
code.
Write a toString method in each class that prints out the name of the
subclass using the getClass() method of class Object followed by the
instance variables, each preceded by a description.
Create a class named MetroCard that can keep track of its balance and
expiration date. Each MetroCard has a unique serial number.
There are different types of metro cards:
Pay-per ride
Unlimited Ride
Reduced Fare (half fare) for senior citizens or disabled individuals,
stores the owner's name
All metro cards have common characteristics. They should inherit from
a common base class.
Create a class that represents the card reader. It can deduct one fare
from the MetroCard. Consider:
What if there is an unexpired transfer that can be used? (Remember:
transfers are only valid on a different route within a specified
amount of time.)
What if the balance is insufficient?
Plan for rate changes. Should the fare be a literal or a variable?
Create another class that represents the metro card vending machine.
It should have the capacity to create new MetroCards and refill
existing cards.
New cards can have a choice of dollar amounts ($4, $10, $20, etc.).
The amount paid is not necessarily the same as the initial balance of
the MetroCard (i.e., $10 might give you $12).
When refilling an old card, the user can either enter an arbitrary
amount OR choose from a list of dollar amounts. If the user enters a
dollar amount not on the list, the card's balance is increased by the
amount paid. If the user chooses an amount from the list, he might
receive a bonus (as in a new card).
Remember that the rates change periodically. Develop the class in a
way that supports this feature.
This system is not complete yet. Which features can you think of that
we missed?