/* * Program: ConeMaker * * This program creates an ice cream cone with five scoops: * ----------- * ( vanilla ) * ----------- * ( vanilla ) * ----------- * ( chocolate ) * ----------- * ( chocolate ) * ----------- * ( vanilla ) * ---------- * \ cone / * \ / * \ / * \ / * \/ */ import treats.*; class ConeMaker { public static void main(String args[]) { // Declare and create necessary objects IceCreamMachine machine = new IceCreamMachine(); Cone waffle = new Cone(); Scoop scoop; // this is used to hold on to the ice cream // scoops that come from the machine // Put on a scoop of vanilla machine.selectVanilla(); scoop = machine.getScoop(); waffle.addScoop(scoop); // Put on a scoop of chocolate machine.selectChocolate(); scoop = machine.getScoop(); waffle.addScoop(scoop); // Add another chocolate scoop // Note: 1) the machine is already set to chocolate // 2) we don't need to use the variable "scoop" to hold on // to the ice cream scoop; we can have the machine dispense // the scoop and put it on the cone in one step. waffle.addScoop(machine.getScoop()); // Add the final two vanilla scoops machine.selectVanilla(); waffle.addScoop(machine.getScoop()); waffle.addScoop(machine.getScoop()); } // end method main } // end class ConeMaker