Create modeling tickets for a city subway system, JAVA Programming

For this assignment you'll create some classes for modeling tickets for a city subway system. The type of system we are modeling has these main features:

Stations are grouped in zones. Each zone is represented by a positive integer. The cost for a ride depends on how many zones are crossed. There is a fixed cost, referred to as the ride cost, to travel within a zone. In addition, the rider pays an additional cost, called the zone cost, which is multiplied by the difference between the zones. For example, if the ride cost is 2.00 and the zone cost is 1.75, then traveling from zone 5 to zone 2 would be 2.00 + 3 * 1.75 = 7.25, since 3 is the difference between 5 and 2. It would be the same to travel from zone 2 to zone 5, of course.

The tickets have a magnetic stripe in which some information is encoded, including a balance. As riders pass through the turnstile to enter the station, they swipe their cards through the card reader on the turnstile. The zone in which the turnstile is located is recorded on the card. When a rider exits the station at his or her destination, the card is swiped at the exit turnstile, and the cost for the trip is subtracted from the balance on the card, if possible. When the balance on the card isn't enough to pay for the trip, the turnstile doesn't open and the card's balance isn't modified.

There is a discounted fare for seniors, a fact which is also recorded on the card. Here is an overview of the roles of the four classes in this system.

A Ticket models a ticket with a magnetic stripe as described above. A ticket has a balance in cents, an indication of whether the user is entitled to discounted fares, and what the start zone is if a trip is in progress.

A TicketMachine creates new Tickets according to various criteria. Users can purchase tickets by selecting a start and end zone, by specifying an amount for the initial balance, or by specifying a number of rides with a given start and end zone. A ticket machine also keeps track of the total number of tickets sold and the total amount of money collected.

The Turnstile type models a turnstile as described above. Each turnstile has a zone in which it is located and has methods swipeIn() for entering a station and swipeOut() for exiting.

The TicketUtil class is a utility for calculating ride costs. It is used by the TicketMachine when dispensing tickets, and it is used by the Turnstile class in order to determine how much to subtract from the balance on a ticket when someone exits.

Note that there is no main() method in any of these classes. In order to test your code, you'll need to create a main class that  constructs some of these objects and checks that they work correctly.

Posted Date: 2/16/2013 1:25:13 AM | Location : United States







Related Discussions:- Create modeling tickets for a city subway system, Assignment Help, Ask Question on Create modeling tickets for a city subway system, Get Answer, Expert's Help, Create modeling tickets for a city subway system Discussions

Write discussion on Create modeling tickets for a city subway system
Your posts are moderated
Related Questions
Ask1. Storing the Array: Write an application that uses an Array to store 10messages of type String. You will store this Array with 10 messages of your choosing. For example, a mes

If we have 2 tables like bankcustomer(cid,cname,addr,acc_type) and customeraccount(cid,amount). How to Deposit amount into the given customer account.?

Java is increasingly used for middleware applications to communicate among Server and clients. Java has features like multithreading, portability and networking capabilities. Chang

This project focuses on demonstrating the understanding of data types, input/output, sequential and selection programming statements, and mathematical operations. The project re

1. Unit tests :There are two popular processes to testing server-side classes: mock objects, which test classes by checking the server container, and in-container testing, which

consider the file name cars.text each line in the file contains information about a car ( year,company,manufacture,model name,type) 1-read the file 2-add each car which is represen

Question Based on the program fragment below, rewrite the outer for loop using: a. while loop b. repeat..until loop

10.13 (CarbonFootprint Interface: Polymorphism) Using interfaces, as you learned in this chapter, you can specify similar behaviors for possibly disparate classes. Governments and

How to Implementing Interfaces in java? To actually utilize this interface you create a class that involves a public double calculateTariff() method and declare in which the cl

The purpose of this assignment is to help you learn the Java environment and practice I/O instructions, assignment, and simple arithmetic operators. Teams: The assignment can