Java - Starting to Program - Concrete tips on how to write thisprogram well?

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?
 
T

timjowers

Create a Java class for each "class" mentioned in the assignment:
public class <thingy> {
// your code goes in here.
}

Once you've identified the domain objects (the "classes") then the
overall logic will be more evident. Hint, you'll want to put each
class in a file with a matching name.
E.g. MetroCard in MetroCard.java. Or just use eclipse and make the new
classes with the menu options.

Welcome to the world of programming.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top