Create modeling tickets for a city subway system, JAVA Programming

Assignment Help:

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.


Related Discussions:- Create modeling tickets for a city subway system

Garbage collection in java, The Java programming language is object-oriente...

The Java programming language is object-oriented and includes automatic garbage collection. Garbage collection is the process of reclaiming memory taken up by unreferenced objects.

Explain the for loop in java, Explain the for loop in java? // This is ...

Explain the for loop in java? // This is the Hello program in Java class Hello { public static void main (String args[]) { System.out.print("Hello "); // Say Hello

Assignments, Define a function that will take a box type of object as argum...

Define a function that will take a box type of object as argument and return a box object whose dimension is 10 times more than the object

What is constructor chaining, What is constructor chaining and how is it ac...

What is constructor chaining and how is it achieved in Java? A child object constructor always first requires to construct its parent (which in turn calls its parent constructo

Need minecraft bukkit plugin programmer, Need Minecraft Bukkit Plugin Progr...

Need Minecraft Bukkit Plugin Programmer I want to make my own server for Minecraft. I am in need of a experts to make custom bukkit plugins for my server. But basically I will w

Write the hashcode() method of java.lang.object, Write the hashCode() metho...

Write the hashCode() method of java.lang.Object Anytime you override equals() you should also override hashCode(). The hashCode() method should ideally return the similar int f

Area under the curve, Write a program to find the area under the curve y = ...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

PROBLEM 2, #The objective is to implement a menu-based system for Bank Acco...

#The objective is to implement a menu-based system for Bank Accounts in order to simulate a very simple banking system. Many structures have to be declared to manage bank accounts.

Converting strings to numeric primitive data types, Converting Strings to N...

Converting Strings to Numeric Primitive Data Types To convert a string which is containing digits to a primitive data type, wrapper classes can help. parseXxx method can be u

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd