TranceAddict Forums

TranceAddict Forums (www.tranceaddict.com/forums)
- Chill Out Room
-- What's wrong with this Java code?...


Posted by Turbonium on Apr-29-2004 21:10:

What's wrong with this Java code?...

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


Posted by Azz3D on Apr-29-2004 21:15:

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...


Posted by Turbonium on Apr-29-2004 21:18:

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.


Posted by whiskers on Apr-29-2004 21:19:

well, what kind of sandwiches are you trying to send?


Posted by Turbonium on Apr-29-2004 21:20:

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!


Posted by whiskers on Apr-29-2004 21:28:

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?


Posted by nchs09 on Apr-29-2004 21:28:

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!


Posted by igottaknow on Apr-29-2004 21:40:

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


Posted by GQMr2 on Apr-29-2004 21:41:

haha I haven't programmed since highschool on Macintosh


Posted by mezzir on Apr-29-2004 22:38:

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;
}


Posted by loconet on Apr-29-2004 22:49:

code:
public void int String sendOutput(int sandwiches, String fCode, String dCode, String cCode)



dude, wtf? 3 return types? Stick with one - in this case probably void


Posted by mezzir on Apr-29-2004 23:25:

quote:
Originally posted by loconet
code:
public void int String sendOutput(int sandwiches, String fCode, String dCode, String cCode)



dude, wtf? 3 return types? Stick with one - in this case probably void

wow i completely missed that
that should take care of the parenthases problem i think?
but still the cannot resolve symbol
this is gonna annoy me


Posted by loca on Apr-29-2004 23:46:

quote:
Originally posted by mezzir
wow i completely missed that
that should take care of the parenthases problem i think?
but still the cannot resolve symbol
this is gonna annoy me


compiles for me if you just put:

code:
public void 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); }


i don't get any symbol resolving error... process completed!



Powered by: vBulletin
Copyright © 2000-2021, Jelsoft Enterprises Ltd.