Answered step by step
Verified Expert Solution
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
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...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started