Please Help,
I’m trying to setup an application that allows a user to build an ice cream cone, I managed to get the Exception file to compile, but the IceCreamCone file gives me the following error message when I try to compile, I think the problem is in the exception file constructor but not sure how to fix:
IceCreamCone.java:16: cannot find symbol
symbol : constructor IceCreamConeException()
location: class IceCreamConeException
throw(new IceCreamConeException());
^
1 error
Can anyone tell me what I am not seeing, I don’t have a lot of experience and in desperate need of guidance.
|
Code:
|
public class IceCreamConeException extends Exception
{
int scoops, scps;
String flavor,flav;
public IceCreamConeException(String flavor, int scoops)
{
flavor = flav;
scoops = scps;
}
}
import javax.swing.*;
public class IceCreamCone
{
private String flavor;
private int scoops;
public static int SCOOP_LIMIT = 3;
public IceCreamCone(String flav, int scps) throws IceCreamConeException
{
flavor = flav;
scoops = scps;
if(scoops > SCOOP_LIMIT)
throw(new IceCreamConeException());
}
}
import javax.swing.*;
import javax.swing.*;
public class ThrowIceCreamCone
{
public static void main(String[] args)
{
int scps;
string flav;
String input;
flav = input;
public ThrowIceCreamCone()
{
setFlavor();
setScoops();
}
input = JOptionPane.showInputDialog(null, "How many scoops of ice cream would you like?");
scps = Integer.parseInt(input);
input = JOptionPane.showInputDialog(null, "what flavor of ice cream would you like?");
try
{
IceCreamCone ic = new IceCreamCone(flav, scoops);
JOptionPane.showMessageDialog(null, "Your ice cream flavor is" + flav + " and has " + scoops + "scoops");
}
catch(IceCreamConeException exception)
{
JOptionPane.showMessageDialog(null, exception.getMessage());
}
} |