import java.io.*; class UseDrinksMachine11 { // Demonstrating that an object of type DrinksMachineF // can be viewed as of type DrinksMachine or BeverageMachone public static void main(String[] args) throws NumberFormatException, IOException { DrinksMachineF machine = new DrinksMachineF(40); DrinksMachine cold = machine; BeverageMachine hot = machine; BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int amount; System.out.print("\nHow much do you want to put in the cold drinks machine? "); amount = Integer.parseInt(in.readLine()); cold.addMoney(amount); System.out.print("When you press the Coke button you get "); System.out.println(cold.pressCoke()); System.out.print("\nHow much do you want to put in the hot drinks machine? "); amount = Integer.parseInt(in.readLine()); hot.addMoney(amount); System.out.println("The amount showing is: "+hot.showMoney()+"p"); System.out.print("When you press the Tea button you get "); System.out.println(hot.pressTea()); } }