hi everyone im shazna i got this mate that has been working ahrd on her java coding and now she is stuck as she lost her original file of the coding she is starting from her older version and she is lost because she cannot figure out what is wrong with it anymore i don't understand any of this cuz i am jus helping her to put it online as she has not got internet at home she goe sthat as she has changed her GUI and this is a very old version of her actuall work she cannot get rid of the errors when she tries to figure out 1 she gets and more errors taht appear so please if some1 can fugure it out pleaseeee HELPPPPP thnakxzzzzzz:)

public abstract class Beverage
{
int sugar;
boolean milk;
public String getMessage()
{
String name = this.getClass().getName();
String sugarMessage = "";
if (sugar == 1) sugarMessage = "one sugar";
if (sugar == 2) sugarMessage = "two sugars";
if (sugar == 0) sugarMessage = "";
return "Vended 1 " + name + (milk ? " with milk " : "") + (sugar==1 || sugar == 2 ? (milk ? "and " + sugarMessage : " with " + sugarMessage) : "");
}
}
public class Coffee extends Beverage
{
public Coffee( int sugar, boolean milk)
{
this.sugar = sugar;
this.milk = milk;
}
}
public class Tea extends Beverage
{
public Tea(int sugar, boolean milk)
{
this.sugar = sugar;
this.milk = milk;
}
}
public class SugarButtonsGroup 
{
private JRadioButton jRadioButton0Sugar = new JRadioButton();
private JRadioButton jRadioButton1Sugar = new JRadioButton();
private JRadioButton jRadioButton2Sugar = new JRadioButton();
private ButtonGroup sugarButtons = new ButtonGroup();
public SugarButtonsGroup()
{
jRadioButton0Sugar.setText("No sugar");
jRadioButton1Sugar.setText("1 sugar");
jRadioButton2Sugar.setText("2 sugars");
sugarButtons.add(this.jRadioButton0Sugar);
sugarButtons.add(this.jRadioButton1Sugar);
sugarButtons.add(this.jRadioButton2Sugar);
}
public int numberOfSugars()
{
if (this.jRadioButton1Sugar.isSelected()) return 1;
if (this.jRadioButton2Sugar.isSelected()) return 2;
return 0;
}
public ButtonGroup getButtonGroup()
{
return sugarButtons;
}
public JRadioButton getJRadioButton0Sugar()
{
return jRadioButton0Sugar;
}
public JRadioButton getJRadioButton1Sugar()
{
return jRadioButton1Sugar;
}
public JRadioButton getJRadioButton2Sugar()
{
return jRadioButton2Sugar;
}
}
public class BeverageButtonsGroup 
{
private JRadioButton jRadioButtonTea = new JRadioButton();
private JRadioButton jRadioButtonCoffee = new JRadioButton();
private ButtonGroup buttonGroup = new ButtonGroup();
public BeverageButtonsGroup()
{
buttonGroup.add(jRadioButtonTea);
buttonGroup.add(jRadioButtonCoffee);
jRadioButtonTea.setText("Tea");
jRadioButtonCoffee.setText("Coffee");
jRadioButtonCoffee.setSelected(true);
}
public String getBeverageName()
{
if (jRadioButtonTea.isSelected()) return "tea";
if (jRadioButtonCoffee.isSelected()) return "coffee";
return "";
}
public ButtonGroup getBeverageButtonGroup()
{
return buttonGroup;
}
public JRadioButton getJRadioButtonTea()
{
return jRadioButtonTea;
}
public JRadioButton getJRadioButtonCoffee()
{
return jRadioButtonCoffee;
}
}
public class MilkCheck 
{
private JCheckBox jCheckBoxMilk = new JCheckBox();
public MilkCheck()
{
this.jCheckBoxMilk.setText("Milk");
}
public JCheckBox getJCheckBoxMilk()
{
return jCheckBoxMilk;
}
public boolean withMilk()
{
return this.jCheckBoxMilk.isSelected();
}
}

public class CoinMechanism
{
private JButton jButton5P = new JButton();
private JButton jButton10P = new JButton();
private JTextField jTextFieldTotal = new JTextField();
private BeverageFactory b;
public CoinMechanism (BeverageFactory b)
{
this.b = b;
reset();
jTextFieldTotal.setEditable(false);
jButton5P.setText("Insert 5 pence");
jButton5P.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
jButton5P_actionPerformed(e);
}
});
jButton10P.setText("Insert 10 pence");
jButton10P.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
jButton10P_actionPerformed(e);
}
});
}
private void jButton5P_actionPerformed(ActionEvent e)
{
// to be completed
}
private void jButton10P_actionPerformed(ActionEvent e)
{
// to be completed
}
private void notifyVend()
{
b.getCoinCurrentTotal(jTextFieldTotal.getText());
}
public void reset()
{
this.jTextFieldTotal.setText("0");
}
public JButton getJButton5P()
{
return this.jButton5P;
}
public JButton getJButton10P()
{
return this.jButton10P;
}
public JTextField getJTextFieldTotal()
{
return this.jTextFieldTotal;
}

}

public class BeverageFactory 
{
private int coffees;
private int teas;
private int milks;
private int sugars;

public BeverageButtonsGroup beverageButtons = new BeverageButtonsGroup();
public SugarButtonsGroup sugarButtons = new SugarButtonsGroup();
public MilkCheck milkCheck = new MilkCheck();
public CoinMechanism slots = new CoinMechanism(this);
public void setUIState()
{
// sets the states of the widgets on the frame accoording to the
// quantities of supplies in the machine
// to be finished
}
public void getCoinCurrentTotal (String o)
{
// this is should be executed whenever a user puts a coin into the machine
int foo = Integer.parseInt(o);
// to be finished
}
private int cost()
{
// returns the cost of the currently selected beverage
// to be finished
}
public BeverageFactory( int coffees, int teas, int milks, int sugars)
{
this.coffees = coffees;
this.teas = teas;
this.milks = milks;
this.sugars = sugars;
}
public void refill(int coffees, int teas, int milks, int sugars)
{
// to be completed
}
public Beverage makeBeverage(String name, boolean milk, int sugar) 
{
if (name.compareTo("coffee") == 0)
{
coffees--;
if (milk) milks--;
sugars = sugars - sugar;
return new Coffee(sugar,milk);
}
if (name.compareTo("tea") == 0)
{
teas--;
if (milk) milks--;
sugars = sugars - sugar;
return new Tea(sugar, milk);
}
return null;
}
} 

PLesae can any1 helppppp:sad: and i dunno how to wrap the code aswellll sorryyyyy i trieddd lol

Edited 3 Years Ago by Dani: Formatting fixed

It seems he downloaded something that he wants to turn in as his homework but he doesn't know what that homework actually is and on top of that all interpunction on his keyboard somehow failed at the same time just as he was typing that message

It seems he downloaded something that he wants to turn in as his homework but he doesn't know what that homework actually is and on top of that all interpunction on his keyboard somehow failed at the same time just as he was typing that message

:lol: And stop emailing me please.

This article has been dead for over six months. Start a new discussion instead.