Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program Specification: 1. Create a new multi-class Java program which implements a vending machine simulator which contains the following functionality: A) At program startup, the

Program Specification:

1. Create a new multi-class Java program which implements a vending machine simulator which contains the following functionality:

A) At program startup, the vending machine is loaded with a variety of products in a variety of packaging for example soda/tonic/Coke in bottles, peanuts in bags, juice in cartons, etc. Also included is the cost of each item. The program should be designed to easily load a different set of products easily (for example, from a file).

Also at program startup, money should be loaded into the vending machine. Money should consist of different monetary objects for the specified currency for example in USD $1 bills, $5 bills, quarters, dimes, etc. Your program should be designed to use different national currencies easily (for example the Euro) without changing source code. Money should be maintained as paper bills and coins, not just amounts.

B) A menu of commands must be provided. The menu should consists of the following commands using the command numbers indicated:

1)Display the list of commands

2)Display the vending machine inventory. For each item, this command should result in displaying a description and current quantity.

3)Display the money currently held in the vending machine.

4)Purchase an item. The result of this selection should be the following actions:

a) Prompt the user to indicate what item to purchase

b) Prompt the user to specify what monetary items are being used for payment (the actual

items for example quarters, dimes, etc.), not a money amount

c) If the user specified enough money to purchase the selected item, the item is purchased

(deducted from inventory), supplied money is added to the vending machine, and any change is returned in the form of monetary items (quarters, dimes, etc.).

d) If the user did not specify enough money for the selected item, the transaction is aborted with the supplied money not added to the machine (not accepted) and the product not purchased (i.e. the state of the vending machine is unchanged).

5. Exit exits the program displaying a departing message.

2. Additional points to consider: A) You can use the Java Standard Edition (SE) API library as supplied by Oracle (AKA Sun) except the collection classes (i.e. not ArrayList, Map, Vector, etc.). These other collections will be covered later in the course.

B) When developing complex classes, consider creating a main() method to test them out. Once tested successfully, delete the main() method.

C) You should generate error messages when appropriate, for example on invalid input values or not enough money supplied for the selected item to purchase. Exceptions will be covered later in the course so for this program displaying appropriate messages on the console is fine.

Each public class must be contained in a separate Java source file. Only one source file will have a main() method and this source will be named VendingMachineSimulator.java. Other source/class names are up to you following the guidelines specified so far in the course.

JavaDocs:

Sources should be commented using JavaDoc-style comments for classes and methods. Each class should have a short comment on what it represents and use the @author annotation. Methods should have a short (usually 1 short sentence) description of what the results are of calling it. Parameters and returns should be documented with the @param and @return annotations respectively with a short comment on each.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Genetic Databases

Authors: Martin J. Bishop

1st Edition

ISBN: 0121016250, 978-0121016258

More Books

Students also viewed these Databases questions

Question

What is an example of a relative cell reference? A$ 1 A 1

Answered: 1 week ago