Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem Description : You will be writing classes that represent various parts of a vending machine. You will need to write two files: VendingMachine.java and

Problem Description: You will be writing classes that represent various parts of a vending machine. You will need to write two files: VendingMachine.java and VendingItem.java. A simple driver class VendingWorld.java (https://cs1331.gitlab.io/fall2018/hw3/VendingWorld.java) has been provided, and it will allow you to interact with your simulation within the command line/terminal.

Solution Description Vendingltem.java (enum) Instances of this enum will represent items in your vending machine. Your boss at Coke has done extensive analysis and determined that the following items and prices are ideal for Georgia Tech students: Price S1.50 1.50 $2.50 Ramblin_Reck Toy $180.75 $30.00 $15.00 $10.00 Graphing Calculator $120.00 S0.10 S3.14 $55.55 1.25 2.50 $4.75 3.15 0.99 Item Lays Doritos Coke Rubiks Cube Rat_Cap FASET_Lanyard UGA Diploma ie Clicker Cheetos Sprite Red Bull Ramen Cold_Pizza The names of the elements in your enum should be exactly as they appear here, and the price should be a parameter to the enum constructor. Your VendingItem enum should have the following fields, methods, and constructors: private final double price. This field is the price of an item, and should be set in the constructor e VendingItem(double price). This is the constructor for the enum type, and it takes the price as its single parameter. Review the links and details in the Background section if this confuses you public double getPrice(). This method is just a simple getter method for the price. price is final and has no setter because it does not make sense for an objects price to change at runtime public String tostring(). This method returns a String representation of a VendingItem for use in your simulation. The string should look like (name): $xx.xx where (name) is the name of the Vendingitem and xx.xx is its priceascii table (https://www.cs.cmu.edu/~pattis/15-1XX/common/handouts/ascii.html)


 

Solution Description Vendingltem.java (enum) Instances of this enum will represent items in your vending machine. Your boss at Coke has done extensive analysis and determined that the following items and prices are ideal for Georgia Tech students: Item Price Lays $1.50 Doritos $1.50 Coke $2.50 Ramblin_Reck_Toy $180.75 Rubiks Cube $30.00 Rat_Cap $15.00 FASET_Lanyard Graphing Calculator $120.00 UGA_Diploma $10.00 $0.10 Pie $3.14 Clicker $55.55 Cheetos $1.25 Sprite $2.50 Red Bull $4.75 Ramen $3.15 Cold Pizza $0.99 The names of the elements in your enum should be exactly as they appear here, and the price should be a parameter to the enum constructor. Your VendingItem enum should have the following fields, methods, and constructors: private final double price. This field is the price of an item, and should be set in the constructor. VendingItem(double price). This is the constructor for the enum type, and it takes the price as its single parameter. Review the links and details in the Background section if this confuses you. public double getPrice(). This method is just a simple getter method for the price. price is final and has no setter because it does not make sense for an object's price to change at runtime. public String tostring(). This method returns a string representation of a VendingItem for use in your simulation. The string should look like: "(name): $xx.xx" where (name) is the name of the vVendingItem and xx.xx is its price.

Step by Step Solution

3.31 Rating (139 Votes )

There are 3 Steps involved in it

Step: 1

Implementation for VendingItem Enum Add all the items provided here in list not copied all of them p... 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 Probability

Authors: Mark Daniel Ward, Ellen Gundlach

1st edition

716771098, 978-1319060893, 1319060897, 978-0716771098

More Books

Students also viewed these Programming questions