Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Task Specification You will implement an electronic ticket for public transport, called MyTi (My Ticket). A MyTi can be “charged” by adding credit to it: initially, a MyTi has zero credit; a MyTi can...

1 answer below »

Task Specification
You will implement an electronic ticket for public transport, called MyTi (My
Ticket).
A MyTi can be “charged” by adding credit to it: initially, a MyTi has zero credit;
a MyTi can hold up to $100 of credit.
Any attempt to add credit that goes above the limit causes an e
or message and
for the charge to fail.
Amounts to be credited to a MyTi must be integer dollar amounts in precise
multiples of $5.00.
Transport passes can be bought using a MyTi ticket: a pass can be for either “2
Hours” or “All Day”, and can be for either “Zone 1” or “Zone 1 and 2”.
Prices are as follows:
o 2 Hour Zone 1 pass: $2.50
o 2 Hour Zone 1+2 pass: $3.50
o All Day Zone 1 pass: $4.90
o All Day Zone 1+2 pass: $6.80
If you attempt to purchase a ticket without sufficient credit on your MyTi ticket
then the attempt fails: no ticket is issued and there is no charge to your ticket.
Part A
Implement a system for managing one MyTi ticket. The system should present a
menu with the following options:
1. Buy a travel pass
2. Charge my MyTi
3. Show remaining credit
0. Quit
Option 1 should query for 2 Hours vs All Day and Zone 1 vs Zone 1+2.
Option 2 should query for an amount.
You should perform the following e
or checking:
For all menus, check that a valid option is selected. If the user selects an
invalid option, then print an e
or message and put the menu back up to let the
user choose again.
For Option 1, check that the user has enough credit to buy the chosen pass.
For Option 2, check that the user enters a valid amount, which does not go
above the maximum.
Do not use object-oriented design for Part A: just implement the required
functionality in a single procedural main program.
Following is a possible sample interaction with the MyTi system. Text in bold would be input from the user:
Welcome to MyTi!
Choose an option:
1. Buy a travel pass
2. Charge my MyTi
3. Show remaining credit
0. Quit
Please make a selection: 3
Your credit = $0.00
Choose an option:
1. Buy a travel pass
2. Charge my MyTi
3. Show remaining credit
0. Quit
Please make a selection: 2
How much do you want to add: 200
So
y, the max amount of credit allowed is $100.00
How much do you want to add: 81
So
y, you can only add multiples of $5.00
How much do you want to add: 10
Your credit = $10.00
Choose an option:
1. Buy a travel pass
2. Charge my MyTi
3. Show remaining credit
0. Quit
Please make a selection: 1
What time period:
a) 2 Hours
) All Day
c) cancel
Your selection: a
Which zone:
a) Zone 1
) Zones 1 and 2
c) cancel
Your selection:
You purchased 2 Hour pass for Zones 1 and 2, costing $3.50
Your remaining credit is $6.50
Choose an option:
1. Buy a travel pass
2. Charge my MyTi
3. Show remaining credit
0. Quit
Please make a selection: 1
What time period:
a) 2 Hours
) All Day
c) cancel
Your selection:
Which zone:
a) Zone 1
) Zones 1 and 2
c) cancel
Your selection:
So
y, you don’t have enough credit for that selection
Choose an option:
1. Buy a travel pass
2. Charge my MyTi
3. Show remaining credit
0. Quit
Please make a selection: 1
What time period:
a) 2 Hours
) All Day
c) cancel
Your selection:
Which zone:
a) Zone 1
) Zones 1 and 2
c) cancel
Your selection: a
You purchased All Day pass for Zone 1, costing $4.90
Your remaining credit if $1.60
Choose an option:
1. Buy a travel pass
2. Charge my MyTi
3. Show remaining credit
0. Quit
Please make a selection: 1
What time period:
a) 2 Hours
) All Day
c) cancel
Your selection: c
Choose an option:
1. Buy a travel pass
2. Charge my MyTi
3. Show remaining credit
0. Quit
Please make a selection: 5
So
y, that is an invalid option!
Choose an option:
1. Buy a travel pass
2. Charge my MyTi
3. Show remaining credit
0. Quit
Please make a selection: 0
Goodbye!
Part B
The aim of Part B is to incorporate basic object-oriented concepts into your program. In particular, create classes for a MyTi ticket and for the different Travel Pass options.
You are to implement one more piece of functionality for Part B:
XXXXXXXXXXPrint purchases
A Purchase is any (successful) purchase of a travel pass. You should keep track of all purchases in an a
ay (or an A
ayList, if you know about those).
Keep track only of successful purchases, not failed attempts.
If you use an a
ay you may assume a maximum of 100 purchases.
Printing the list of purchases from the interaction in Part A would look like this:
Options:
1. Buy a travel pass
2. Charge my MyTi
3. Show remaining credit
4. Print purchases
0. Quit
Please make a selection: 4
Purchases:
Purchased 2 Hour pass for Zones 1 and 2, costing $3.50
Purchased All Day pass for Zone 1, costing $4.90
Tips:
A travel pass object should know information about itself: e.g. how long it lasts (2hours or 24 hours), which zones it covers, how much it costs
You’ll want a superclass of the different types of travel passes; the superclass
should have defaults of the methods that return the above values. Even better, the
superclass could be abstract, and have abstract methods. (You’ll learn about
these!)
Each travel pass object should know how to print itself (or convert itself to a
String that can be printed).
Submission Instructions
1. Submit all Java files for Part A and Part B. Submit only *.java files; do not submit *.class files! It is your responsibility to ensure that your code compiles and runs under Eclipse!!!
2. Follow good coding styles, proper commenting
of your code, consistent indentation, not “hard-coding” fixed values or assumptions,
3. Please include a README with insutructions on how to run and test/demonstrate your program.
4. If you have developed your assignment using IntelliJ IDEA, please submit the whole Project.
Note: - Please Use only IntelliJ IDEA.
Answered Same Day Mar 17, 2022

Solution

Vibhav answered on Mar 17 2022
94 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here