ok so i have a problem here...
i have 2 classes and one is calling another:
public class DinnerMenu implements ItemListener { ... //beginning of code soup watery = new soup(); int dollar = 0; public void itemStateChanged(ItemEvent e) { dollar += watery.getchangedollar(); ... //rest of code } ... //rest of code }
and the second class is:
public class soup { ... // beginning of code public int getchangedollar() { if (van.getStateChanged()==true) return 2; else if (veg.getStateChanged()==true) return 3; else if(broth.getStateChanged()==true) return 4; } ... //rest of code }
i get an error: "missing return statement"
why?
also i tried to fix it by changing the second class:
public class soup { ... // beginning of code public int getchangedollar() { int x; if (van.getStateChanged()==true) x=2; else if (veg.getStateChanged()==true) x=3; else if(broth.getStateChanged()==true) x=4; return x; } ... //rest of code }
and there i get another error: "x might not have been initialized"
any help on why im getting these errors would be great, thanks
Dont be that guy