Results 1 to 8 of 8
  1. #1
    TeeTee123 is offline Member
    Join Date
    Dec 2008
    Posts
    2
    Rep Power
    0

    Default Really need Help

    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.



    Java 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());
    
      }
    
    
    }

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quite same question have discuss several times on our community. May be all are from the same class, everyone get the same assignment.

    You get the error on this line,

    Java Code:
    throw(new IceCreamConeException());
    saying that you don't have that constructor in your relevant class. Basically you don't have define the default constructor. If you define non-default constructor in a class VM not automatically call the default constructor. You must define it if you want to use.

  3. #3
    fishtoprecords's Avatar
    fishtoprecords is offline Senior Member
    Join Date
    Jun 2008
    Posts
    571
    Rep Power
    7

    Default

    As a smart person says: Use an appropriate Subject. "Help, urgent!" isn't one.

    "really need help" is another example of an inappropriate and useless subject

  4. #4
    TeeTee123 is offline Member
    Join Date
    Dec 2008
    Posts
    2
    Rep Power
    0

    Default

    What????????????

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    The title of your thread here is your best way of broadcasting to us just what your problem is, kind of like the headline of a newspaper. Just as if you create a decent and informative newspaper headline, more people will read the article, if you create a decent and informative Thread subject heading more people will read your thread and help you.

    Which do you think is more informative, this?
    "Error when throwing exception"

    or this?
    "Really need help"

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by TeeTee123 View Post
    What????????????
    Just look at my signature, may be fishtoprecords pointed on that.

    And also, don't keep quite. If you have found the solution better to mention here. Seems you are not even look at the thread for a long time.

  7. #7
    fishtoprecords's Avatar
    fishtoprecords is offline Senior Member
    Join Date
    Jun 2008
    Posts
    571
    Rep Power
    7

    Default

    Quote Originally Posted by Eranga View Post
    Just look at my signature, may be fishtoprecords pointed on that.
    Not "may be" but for sure.

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •