James Madison University Design Solution Programming Task
Programming Assignment 3/4Scenario:
As you enter into the work force, as a junior Java developer, you decide to write a program to improve
your Java skills. You decide to write a program that mimics the use of a vending machine. A vending
machine can have a maximum of 30 slots.
Each slot is identified by a slot identifier (must be two characters long with the first character as
uppercase letter and the last character as a digit), item name, item price, amount in inventory, and the
amount sold. You may assume that the user will not enter two slots with the same. Additionally, each
slot should track how many slots are in use and the total cost earned (item price * amount sold).
Create a program with a menu that allows a user to select one of the following options:
1) Add Slot – This option will allow a user to create a slot by entering the slot identifier, item name,
item price, and amount in stock. However, if the maximum number of slots (30) has already
been reached, an error message should display instead.
2) Empty Slot – This option will allow a user to a user to remove a slot from the vending machine.
To enable this, the user must first see a list of all the slots available. The user may then select
which slot to delete. However, if the user chooses an invalid slot, or if there are no slots to
choose from, the user should be provided with an error message.
3) Purchase Item – This option will allow a user to purchase one item at a time. The user should be
provided with a list of the items available. If the choses an item has that the available inventory,
then they should see a message that says that the item has been dispensed. If the user chooses
a Slot that has no inventory in stock, then user should be provided with an error message.
4) Display Items – This option will allow a user to view all information about all entered slots to
include the slot identifier, item name, item price, amount in inventory, amount sold, total
earned. However, if there are no slots, the user should be provided with an error message.
5) Exit the Program – This option will provide a final report showing the current number of Slots
entered and total amount of money earned from slot.
Upon completion of the action from the menu item, the user should be prompted to select another
menu item. This will continue until the user has selected to exit the program.
Page 1 of 4
Copyright ©2019 John Bono, Ph.D. All rights reserved.
Other Requirements:
•
•
•
•
•
•
•
•
You may assume a user will NOT enter two Slots with the slot identifer.
Your solution must use object-oriented techniques (No points earned for a procedural solution).
Your solution must demonstrate use of arrays
Your solution must be designed as a modular solution using methods other than main, with each
method performing one task.
Your solution must include appropriate constants, constructors, accessors, mutators, and special
purpose methods (including a toString() method) with exception handling, as necessary in
support of the problem.
Your solution must not import any Java library other than JOptionPane.
You may not use System.exit, or any variant that exits the program in the middle of the
program. The program should only exit once the algorithm has finished completing.
Your solution may not use any functions or language constructs not covered during IT 106 or this
semester’s IT 206 without prior authorization from your instructor, even if you know other
functions or language constructs. We want everyone to be on the same “playing field”,
regardless of previous programming exposure, and get practice with algorithmic design to solve
problems (the intent of the course). Using something existing not discussed in class does not
give you as much practice as solving the problem yourself. Doing this may lead to a substantial
grade penalty, a grade of zero, or an Honor Code inquiry. When in doubt, ask!
Hints:
•
•
•
Don’t forget what you learned about working with array insertions and deletions from IT 106.
Think about what type of validations might be appropriate for this application. Make sure these
are all handled.
Remember the methods summarizing data on multiple objects should be created in the
implementation class
Page 2 of 4
Copyright ©2019 John Bono, Ph.D. All rights reserved.
To Do (Check Blackboard for Due Dates):
Programming Assignment 3: Solution Design
1) List and describe the purpose of each class that will be needed to solve this problem
a. You must separately identify (list) and describe the purpose of each class. One or two
sentences per class should be sufficient.
2) Data Definition Class(es) – Create a detailed UML Class Diagram, listing and explaining all class
variables, accessors, mutators, special purpose methods, and constructors associated to each
data definition class.
3) Implementation Class – Create a table that lists all methods that will be used to create the
implementation class. For each method identified, provide the following:
a. A 1-2 sentence describing the purpose of the method
b. A list of the names, data types, and brief description (1-2 sentences) for each input
variable into the method, if there are any
c. The name and data type of the variable to be returned from the method, or void if
nothing will be returned
Note: You do not need to provide any pseudocode. However, you should create a plan for
yourself as to how you will perform the logic for each method. If you do not do this, you will
have great difficulty in completing the solution implementation.
An example format to use for this table is as follows. You can format this table in any way you’d
like, so long as the information is clearly presented. Completing this table correctly will help you
build your documentation and code for your solution implementation.
Method:
Purpose:
Inputs:
Return:
Method:
Purpose:
Inputs:
Return:
getMagazine
The method will allow for the creation and population of a Magazine object
based on user input of a title, cost, and number in stock
none
magazine : Magazine – The Magazine object created and populated from user
input
checkout
The method will allow for the purchase of a magazine. It takes into account the
sales tax that will be charged as part of the cost calculation
magazine : Magazine – The magazine to be purchased
salesTax : double – The sales tax percentage to be charged as part of the
checkout
void
Page 3 of 4
Copyright ©2019 John Bono, Ph.D. All rights reserved.
Upload a Word document containing only items above to Blackboard.
Grading Criteria
Requirement
Points
List and describe the class(es) needed to solve the problem
10
Data Definition Class Design – Detailed UML Diagram
40
Implementation Class Design – Table Listing All Methods
50
Programming Assignment 4: Solution Implementation
Write a well-documented, efficient Java program that implements the solution design you identified.
Include appropriate documentation as identified in the documentation expectations document.
To Blackboard, submit ONLY ONE .zip file containing all of the .java files part of your submission for your
solution implementation. As you are naming your Java files, make sure they are indicative to the
purpose of the file. Do not include your name in the file name or use generic names, such as
Assignment2.java. Your .zip file should contain only the .java files in your solution. Be careful that you
do not submit .class files instead of .java files.
Warning! You must submit ONLY ONE .zip file containing ONLY your .java files. Failure to follow
this instruction precisely will result in a 10 point deduction of the assignment score. No
exceptions!
Why is this important? The goal is to teach you how to properly package your IT solutions into a
“customer-friendly” format while paying attention to “customer” requirements provided to you.
Your program must compile using jGrasp. Any final program that does not compile, for any reason, will
receive an automatic zero. Other IDEs often place in additional code that you are unaware of, doing too
much of the work for you. You are strongly discouraged from using IDEs other than jGrasp.
Grading Criteria
Requirement
Implementation of object-oriented Java program, using efficient practices, such as the use of
constants, good variable names, information hiding, no redundant code, etc.
Appropriate objective-style documentation
Appropriate intermediate comments
Points
70
10
20
Page 4 of 4
Copyright ©2019 John Bono, Ph.D. All rights reserved.
Top-quality papers guaranteed
100% original papers
We sell only unique pieces of writing completed according to your demands.
Confidential service
We use security encryption to keep your personal data protected.
Money-back guarantee
We can give your money back if something goes wrong with your order.
Enjoy the free features we offer to everyone
-
Title page
Get a free title page formatted according to the specifics of your particular style.
-
Custom formatting
Request us to use APA, MLA, Harvard, Chicago, or any other style for your essay.
-
Bibliography page
Don’t pay extra for a list of references that perfectly fits your academic needs.
-
24/7 support assistance
Ask us a question anytime you need to—we don’t charge extra for supporting you!
Calculate how much your essay costs
What we are popular for
- English 101
- History
- Business Studies
- Management
- Literature
- Composition
- Psychology
- Philosophy
- Marketing
- Economics