I have two classes....Interface and Coffee. The InterFace is basically an options screen where the user chooses a coffee they want from a ComboBox....once the choice is made they click a JButton and the value is stored in the object String coffeeType. The second class is where the coffee styles and amount are set.
I want to know how I can take the value in coffeeType into the other class Coffee and put it into its' appropriate instance so I can then deduct the amounts from a container class?
//Import the relevent classes import java.awt.*; import java.awt.event.*; import javax.swing.*;
//define the class and set the properties for the Interface public class InterFace extends JFrame implements ActionListener{
int coffee; int milk; int water; Coffee(int coffeeRequired, int milkRequired, int waterRequired) { coffee=coffeeRequired; milk=milkRequired; water=waterRequired; } }
public defineCoffeeAmount { //amount of coffee, milk and water required for this instance of Coffee Coffee darkCoffee = new Coffee(30,0,100); Coffee whiteCoffee = new Coffee(20,40,100); Coffee extraStrongCoffee = new Coffee(40,20,100);