code:import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Freddie extends Applet implements ItemListener
{
int sandwiches = 0;
String fCode="", dCode="", cCode="";
Label sandwichPromptLabel = new Label("Number of sandwiches ordered:");
TextField sandwichInputField = new TextField(5);
Label friesLabel = new Label("Fries serving size: ");
CheckboxGroup friesGroup = new CheckboxGroup();
Checkbox smallFries = new Checkbox("Small",false,friesGroup);
Checkbox mediumFries = new Checkbox("Medium",false,friesGroup);
Checkbox largeFries = new Checkbox("Large",false,friesGroup);
Label drinkLabel = new Label("Drink serving size: ");
CheckboxGroup drinkGroup = new CheckboxGroup();
Checkbox smallDrink = new Checkbox("Small",false,drinkGroup);
Checkbox mediumDrink = new Checkbox("Medium",false,drinkGroup);
Checkbox largeDrink = new Checkbox("Large",false,drinkGroup);
Label condimentsLabel = new Label(" Condiments: ");
Checkbox catsupBox = new Checkbox("Catsup");
Checkbox mustardBox = new Checkbox("Mustard");
Checkbox picklesBox = new Checkbox("Pickles");
Label outputLabelSandwiches = new Label("");
Label outputLabelDrink = new Label("");
Label outputLabelFries = new Label("");
Label outputLabelCondiments = new Label("");
Label warningLabel = new Label("");
public void init()
{
setBackground(Color.red);
add(sandwichPromptLabel);
add(sandwichInputField);
sandwichInputField.requestFocus();
add(friesLabel);
add(smallFries);
smallFries.addItemListener(this);
add(mediumFries);
mediumFries.addItemListener(this);
add(largeFries);
largeFries.addItemListener(this);
add(drinkLabel);
add(smallDrink);
smallDrink.addItemListener(this);
add(mediumDrink);
mediumDrink.addItemListener(this);
add(largeDrink);
largeDrink.addItemListener(this);
add(condimentsLabel);
add(catsupBox);
catsupBox.addItemListener(this);
add(mustardBox);
mustardBox.addItemListener(this);
add(picklesBox);
picklesBox.addItemListener(this);
add(outputLabelSandwiches);
add(outputLabelFries);
add(outputLabelDrink);
add(outputLabelCondiments);
add(warningLabel);
}
//This method is triggered by the user clicking an option button
public void itemStateChanged(ItemEvent choice)
{
try
{
sandwiches = getSandwiches(0);
fCode = getFries("");
dCode = getDrink("");
cCode = getCondiments("");
sendOutput(sandwiches,fCode,dCode,cCode); <<<<< cannot resolve symbol
}
catch (NumberFormatException e)
{
warningLabel.setText("You must enter an integer value.");
sandwichPromptLabel.setText("");
sandwichPromptLabel.requestFocus();
}
}
public int getSandwiches(int sandwiches)
{
sandwiches = Integer.parseInt(sandwichInputField.getText());
return sandwiches;
}
public String getFries(String fCode)
{
fCode = "";
if (smallFries.getState()) fCode = "Small";
else
if (mediumFries.getState()) fCode = "Medium";
else
if (largeFries.getState()) fCode = "Large";
return fCode;
}
public String getDrink(String dCode)
{
dCode = "";
if (smallDrink.getState()) dCode = "Small";
else
if (mediumDrink.getState()) dCode = "Medium";
else
if (largeDrink.getState()) dCode = "Large";
return dCode;
}
public String getCondiments(String cCode)
{
cCode = "";
if (catsupBox.getState()) cCode = "1";
else
if (mustardBox.getState()) cCode = "2";
else
if (picklesBox.getState()) cCode = "3";
return cCode;
}
public void int String sendOutput(int sandwiches, String fCode, String dCode, String cCode)
{
outputLabelSandwiches.setText("# of sandwiches ordered: " + sandwiches);
outputLabelFries.setText("Size of fries ordered: " + fCode);
outputLabelDrink.setText("Size of drink ordered: " + dCode);
outputLabelCondiments.setText("Condiments ordered: " + cCode);
}
} <<<<< '(' expected
compiler errors are bolded in orange and described
Last edited by Turbonium on Apr-29-2004 at 21:19
Apr-29-2004 21:10
Azz3D
Asobi Seksu'd
Registered: Jul 2002
Location:
I don't know anything about java, but just a thought:
to make it easier to read use the [.code] tag. it lines up the brackets and makes the spacings look like on the compiler...
___________________
Summary of an ASOT episode:
- The newest tunes selected!!!! the hottest tracks in a row!!!! here is your host arrrrrmin van buuuuuuuuhreeennnnnhnnhhn
- hello and welcome glad u cud join us this is a state of trance episode blah blah blah
- waaaaaaaaaaaaaaaaaaah waaaaaaaaaaaaah whineeeeeeeeeeeee blah blaaaaaaaaah
- that was the newest track by blah bla and before that was blaaaaaaah
- waaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa....the end
Vomit-inducing trifecta tunage: Zocalo | Summer Dream | Shivers
Apr-29-2004 21:15
Turbonium
Supreme tranceaddict
Registered: Jan 2003
Location: Toronto
quote:
Originally posted by Azz3D
I don't know anything about java, but just a thought:
to make it easier to read use the [.code] tag. it lines up the brackets and makes the spacings look like on the compiler...
Yea, it definitely needed that. Thanks.
Apr-29-2004 21:18
whiskers
old skool
Registered: Sep 2001
Location: in your dreams
well, what kind of sandwiches are you trying to send?
___________________
Apr-29-2004 21:19
Turbonium
Supreme tranceaddict
Registered: Jan 2003
Location: Toronto
quote:
Originally posted by whiskers
well, what kind of sandwiches are you trying to send?
integer value ones, you dumbass
go back to programming class you n00b!
Apr-29-2004 21:20
whiskers
old skool
Registered: Sep 2001
Location: in your dreams
quote:
Originally posted by Turbonium
integer value ones, you dumbass
there's your problem, your sandwiches don't have any cheese in them, how can you have sandwiches without any cheese?
___________________
Apr-29-2004 21:28
nchs09
Traceaddict in training
Registered: Sep 2003
Location: Inside your mum
quote:
Originally posted by whiskers there's your problem, your sandwiches don't have any cheese in them, how can you have sandwiches without any cheese?
ya DUH! sandwhich with out cheese. suckz0r!
___________________
quote:
Originally posted by Halcyon+On+On
OOKA-OOKA ME NACHOS ME PRESS KEYS ON COMPUTER GOOD
Apr-29-2004 21:28
igottaknow
PerfectTeeth R4 Dinosaurs
Registered: Feb 2001
Location: The Future
all this programming talk making me hungry...
while your at it would you mind sending me an italian assorted with the works thanks in advance
___________________
GIGANTIC CUNT
Apr-29-2004 21:40
GQMr2
Supreme tranceaddict
Registered: Nov 2002
Location: Zoo York, NY
haha I haven't programmed since highschool on Macintosh
___________________
http://vandiemen.mypodcast.com
lf a desire which no experience in this world can satisfy, the most probable explanation is that I was made for another world." - C.S.Lewis
"everything is within walking distance, if you have the time." - Steven Wright
Apr-29-2004 21:41
mezzir
BEES?
Registered: Nov 2002
Location: assachusetts
yo i swear you need curly brackets to do if statements
so like instead of
if (smallFries.getState()) fCode = "Small";
else
....
return fCode;
you'd do:
if (smallFries.getState())//*is this a boolean?*/{ /* <-- { = then
fCode = "Small"
}else{
......
return fCode;
}