Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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.

Java, Programming

  • Category:- Java
  • Reference No.:- M9522289

Have any Question?


Related Questions in Java

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Part a specification - robot simulationpart a

PART A Specification - Robot Simulation PART A Requirements To complete this assignment you will use the supplied eclipse project Robot P1/. It is already set up to execute a simple arm movement loop which you will build ...

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Project requirementsfor the problem described in the next

Project requirements For the problem described in the next section, you must do the following: 1. include your student ID at the end of all filenames for all java code files. Three classes have been identified in section ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As