public interface Sellable {
public int getPrice();
public String getName();
}
import java.util.Scanner;
public class Automat implements Sellable {
Scanner s = new Scanner(System.in);
public int credit = 0;
public int price;
public String name;
public static Sellable[][] produse = new Sellable[3][1];
public int getPrice(){
return price;
}
public String getName() {
return name;
}
public void insertCoins(int quantity){
System.out.println("Please insert credit");
credit += s.nextInt();
}
public void sellProductAtIndex(int index){
System.out.println("Please Select Drink");
System.out.println();
Scanner input = new Scanner(System.in);
while (true) {
System.out.println(" Press 0 to Select CocaCola");
System.out.println(" Press 1 to Select Pepsi");
System.out.println(" Press 2 to Select 7Up");
System.out.println();
int choice = input.nextInt();
while (choice < 1 || choice > 3) {
System.out.println("Please pick a valid product");
System.out.print("Your Choice :");
choice = input.nextInt();
}
if(choice==1 && produse[0][0].equals(0)){
System.out.println("Out of order please select another product");
}
else if(choice==1 && (produse[0][0]>0) )
}
}
public static void main(String [] args){
produse[0][0]= new CocaCola(2, 10);
produse[1][0]= new Pepsi(1,5);
produse[2][0]= new Zup(3,3);
}
}
public class CocaCola implements Sellable{
public int price = 2;
public String name = "CocaCola";
public int buc = 10;
public CocaCola(int price, int buc){
this.price = price;
this.buc = buc;
}
public int getPrice(){
return this.price;
}
public String getName(){
return this.name;
}
}
and so forth.....

New Topic/Question
Reply


MultiQuote




|