Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A. Case Study: Train stations often provide ticket machine that print a ticket when a customer inserts the correct money for their fare. The

image

A. Case Study: Train stations often provide ticket machine that print a ticket when a customer inserts the correct money for their fare. The ticket machine works by customers 'inserting' money into them, and then the machine will print the ticket if the amount of money inserted is sufficient. Note that, for this nave ticket machine, the fare is fixed which is RM7.50. However, if the amount of money inserted by the customer is insufficient, the machine will ask the customer to insert more money until the amount is sufficient, and then print the ticket as well as the balance. This machine keeps running total of the amount of money it has collected for the ticket fare, total amount of money inserted by the customer, and the total balance it has offered to the customer throughout the operation. Once the machine stops, the total amount collected, and the total balance for all customers throughout the operation will be displayed. Note: The machine is for buying ticket only, and it does not store passenger's information. Question 1: Identify 1 single object, including its attributes and behaviours for the above case study. Object Attributes and its data types Behaviours Question 2: Draw UML based on (1) above. Question 3: Translate the above UML into class definition. Question 4: Write a Java application class to do simulation. Ask user to insert amount of money to buy a ticket. " " If the money is sufficient, print the ticket and produce the balance if any. If the money is insufficient, the machine will ask the customer to insert more many until the amount is sufficient. The machine will only stop if the user requests to stop. Upon stop, the machine will display the followings: i. Total ticket sold. ii. iii. iv. Total amount of money collected from the ticket sold. Total amount of money inserted by the customer. Total balance it has offered (dispense) to the customer.

Step by Step Solution

3.42 Rating (149 Votes )

There are 3 Steps involved in it

Step: 1

Lets break down the requirements for our ticket machine Object TicketMachine Attributes fare Fixed fare for the ticket RM750 totalCollected Total amou... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Materials Management

Authors: Arnold J. R. Tony, Gatewood Ann K., M. Clive Lloyd N. Chapman Stephen

8th edition

9386873249, 134156323, 978-9386873248

More Books

Students also viewed these Programming questions

Question

what is an annuity in which the cash flows continue forever?

Answered: 1 week ago

Question

4. How does a sex-linked gene differ from a sex-limited genepg105

Answered: 1 week ago

Question

6. How does an epigenetic change differ from a mutationpg105

Answered: 1 week ago