do I get my program to incorporate all of my files and not just VendingMachine1.java? It seems to be getting stuck on that part and not incorporating the other classes and files. Bucket.java Coin.java Inventory.java Item.java NotFullPaidException.java NotSufficientChangeExectption.java SoldOutException.java VendingMachine.java VendingMachine1.java VendingMachineImpl.ja
How do I get my program to incorporate all of my files and not just VendingMachine1.java? It seems to be getting stuck on that part and not incorporating the other classes and files.
Bucket.java
Coin.java
Inventory.java
Item.java
NotFullPaidException.java
NotSufficientChangeExectption.java
SoldOutException.java
VendingMachine.java
VendingMachine1.java
VendingMachineImpl.java
This is VendingMachine1.java:
import java.util.Scanner;
public class VendingMachine1 {
public static void main(String[] args) {
VendingMachineImpl vm = new VendingMachineImpl();
//showmenuItem(coin, drink, quantity);
Inputcoin(vm);
InsertItem(vm);
//showdrinks(drink);
//showbalance(sumcoinInsert, price);
}
public static void Inputcoin(VendingMachineImpl vm )
{
int coinInsert, sumcoinInsert=0;
int flag=0;
do{
Coin[] coins = Coin.values();
Scanner sc= new Scanner(System.in);
System.out.println(" Insert the new coins - 1,5,10,25");
coinInsert= sc.nextInt();
for(Coin coin:coins){
if(coin.getDenomination() == coinInsert){
vm.InsertCoin(coin);
sumcoinInsert += coinInsert;
break;
}
}
System.out.println("Do you want to insert more coins (y/n)?");
String choice = sc.next();
if(choice.equalsIgnoreCase("y")){
flag =1;
}
else
{
flag =0;
}
}while(flag !=0);
System.out.println(" Total " +sumcoinInsert);
}
public static void InsertItem(VendingMachineImpl vm )
{
Scanner sc = new Scanner(System.in);
String insertedItem=null;
int itemflag=0;
int insertedQty;
do{
System.out.println("Insert ITEM <coke,pepsi,soda> ");
insertedItem = sc.next();
System.out.println("Insert Quantity ");
insertedQty = sc.nextInt();
Item[] items = Item.values();
for(Item item:items){
if(item.getName().equals(insertedItem) ){
Item insertItem = item;
vm.SelectItemAndGetPrice(insertItem);
break;
}
}
System.out.println("Do you want to Insert more Item(y/n) ");
String isMoreItem =sc.next();
if(isMoreItem.equals("y")){
itemflag=1;
}else{
itemflag=0;
}
}while(itemflag==1);
}
}
Step by step
Solved in 3 steps