Question: Programming Language: JAVA Following classes: Product.java , Coin.java , CoinSet.java , VendingMachine.java , VendingMachineMenu.java Coin.java public class Coin { value = coins value(0.05,0.25,1.0); name(Nickel, Quarter,

Programming Language: JAVA

Following classes: Product.java , Coin.java , CoinSet.java , VendingMachine.java , VendingMachineMenu.java

Programming Language: JAVA Following classes: Product.java , Coin.java , CoinSet.java , VendingMachine.java

Coin.java

public class Coin {

value = coins

value(0.05,0.25,1.0);

name(Nickel, Quarter, Dollar)

public String getCoins{

returngetCoins;

}

//Constructor Get & Set

toString()

}

CoinSet.java

public class CoinSet {

ArrayList set;

//Constructor

//Get & Set Methods

voidaddCoins(Coin);

doublegetValue();

void addCoins;

}

Product.java

public class Product {

private String description;

private double price;

privateint quantity;

//Constructor

public Product(String des, double pce, intqty) {

description = des;

price = pce;

quantity = qty;

}

//Description

public String getDescription() {

return description;

}

public double getPrice() {

return price;

}

public int getQuantity() {

return quantity;

}

public void setDescription(String des) {

description = des;

}

public void setPrice(double pce) {

price = pce;

}

public void setQuantity(int qty) {

quantity = qty;

}

public String toString() {

return description + "@$" + price;

}

}

VendingMachine.java

importjava.util.ArrayList;

public class VendingMachine {

ArrayList products;

CoinSet coins;

CoinSetcurrentCoins;

//Constructors

//Get all the type of products in the vending machine

//Return an array of products add in this machine

ArrayList types = newArrayList ();

for(Product p: products)

if(!types.coin(p)) {

{(type.add(p));

}

Product[] r = new Product [types.size()]

for()

r[i] = types.get(i);

return r;

voidaddCoins (Coin c)

//Add c to current coins

doubleremoveMoney()

// coins --> money

void addProduct(Product p, int q)

for (inti = 1,..)

product.add(p)

voidbuyProduct(Product p)

//remove the products

product.get(i);

if(p.equals(prod))

payment = //Current coins

if(p.getPrice)

products.remove(i){

coins.add(Current coins)

currentcoins.removeAll;}

}

VendingMachineMenu.java

public class VendingMachineMenu {

private Scanner in;

Coin coins [] = {.}

Vending Machine() {

in = ;

}

void run (VendingMachine m)

}

Problem Write a program that simulates a vending machine. Products can be purchased by inserting coins with a value at least equal to the cost of the product. A user select a product from a list of available products, add coins, and either gets the products or gets the coins returned. The coins are returned if insufficient money was supplied or if the product it's sold out. The machine does not give change if too much money was added. Products can be restocked and money remove by an operator. Your solution should include a class VendingMachine that is not coupled with the Scanner or PrintStream classes Sample output S)how products IDnsert coin B)uy A)dd product R)emove coins Quit Description Cookie Price: 2.00 Quantity: S)how products I)nsert coin B)uy A)dd product R)emove coins Quit Price: 1.00 Quantity: S)how products I)nsert coin B)uy A)dd product R)emove coins Quit Cookic @ $2.0 Candy @ $1.0 S)how products Insert coin B)uy A)dd product R)emove coins Quit A) Cookie @ $2.0 B) Candy @ $1.0 Insufficient money S)how products IDnsert coin B)uy A)dd product R)emove coins Quit A) nickel @ 005 B) dime@ 0.1 C) quarter @ 025 D) dollar @ 1.0 S)how products Dnsert coin B)uy A)dd product R)emove coins Q)uit A) nickel @ 0.05 B) dime @ 0.1 C) quarter @ 025 D) dollar @ 1.0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!