Results 1 to 11 of 11
  1. #1
    Promisha is offline Member
    Join Date
    Mar 2011
    Posts
    10
    Rep Power
    0

    Default Cannot Find Symbol

    I'm trying to finish this assignment and I have one little issue I cant get to go away

    import java.util.Scanner;

    final class Circle
    {

    Scanner stdIn = new Scanner (System.in);

    private double diameter;
    private double radius;
    private double circumfrence;
    private double pi = 3.14159;


    public Circle(int newRadius, int newCircumfrence)
    {
    setRadius(newRadius);
    }

    public int getRadius()
    {
    System.out.println("Please Enter a positive number for the Radius");
    radius = stdIn.nextInt( );

    return (int) (double) radius;
    }

    public int getCircumfrence()
    {
    return (int) (double) (pi*2*radius);
    }

    public void setRadius(double newRadius)
    {
    radius = newRadius;
    }

    public void setCircumfrence(int newCircumfrence, int Circumfrence)
    {
    Circumfrence = newCircumfrence;
    }

    public double getArea()
    {
    return pi*(radius*radius);
    }

    public double getDiameter()
    {
    return radius*2;
    }

    }

    public class CircleDemo
    {
    public static void main(String args[])
    {
    int circle = 0;


    Circle circ = new Circle(); //ERROR HERE

    System.out.println("Area is: " + circ.getArea());
    System.out.println("Cicumfrence is: " + circ.getCircumfrence());
    System.out.println("Diameter is: " + circ.getDiameter());



    }
    }


    Just above on the line Circle Circ = new circle();

    Netbeans says:
    Cannot Find Symbol
    Symbol: Constructor Circle()
    location: class circle


    I'm new to this type of thing, and frankly, I suck. :(
    Any Suggestions to how I get rid of this and get it to compile?

  2. #2
    Solarsonic is offline Senior Member
    Join Date
    Mar 2011
    Posts
    261
    Rep Power
    4

    Default

    In your Circle constructor you require 2 ints as parameters. When you tried creating a Circle object you didn't supply the required parameters.

  3. #3
    Promisha is offline Member
    Join Date
    Mar 2011
    Posts
    10
    Rep Power
    0

    Default

    Quote Originally Posted by Solarsonic View Post
    In your Circle constructor you require 2 ints as parameters. When you tried creating a Circle object you didn't supply the required parameters.
    Sorry but could you be a bit more specific as to what I need to do? I have issues understanding all this stuff :(

  4. #4
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    The default constructor is supplied by the compiler if you don't provide any constructors. The second you provide a constructor the compiler stops providing a default constructor. You are attempting to create a circle with a default constructor that doesn't actually exist.

    A default constructor is one that does not take any arguments.

  5. #5
    Promisha is offline Member
    Join Date
    Mar 2011
    Posts
    10
    Rep Power
    0

    Default

    Quote Originally Posted by sunde887 View Post
    The default constructor is supplied by the compiler if you don't provide any constructors. The second you provide a constructor the compiler stops providing a default constructor. You are attempting to create a circle with a default constructor that doesn't actually exist.

    A default constructor is one that does not take any arguments.
    I have no idea what you just said :confused:

  6. #6
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    If you don't know what I said I suggest you read your text book or the java tutorials. What I said was not very advanced. Read up on what a constructor is and what I said should make more sense, if it doesn't make more sense after some reading, come back and let me know and I will help you out.

  7. #7
    Solarsonic is offline Senior Member
    Join Date
    Mar 2011
    Posts
    261
    Rep Power
    4

    Default

    Quote Originally Posted by Promisha View Post
    I have no idea what you just said :confused:
    Ok, as Sunde said, I would advise you learn about object-oriented programming (considering Java is the most OO language and this is very important stuff.)

    But let me show to you simply:

    You made a constructor like this:
    Java Code:
    public Circle(int param1, int param2)
    But when you called the constructor to create a new Circle object, you didn't supply the parameters you specified in your constructor (the two ints).

    This is what you did:
    Java Code:
    Circle c = new Circle();
    Here is what you should be doing to satisfy the requirements of your constructor:
    Java Code:
    int a;
    int b;
    Circle c = new Circle(a, b);

  8. #8
    Promisha is offline Member
    Join Date
    Mar 2011
    Posts
    10
    Rep Power
    0

    Default

    Still can't get it to work. We just barely talked about OOP last class and I'm just confused. I just want exactly what I need to do to get this to work. I just wanted to try programming and I don't really understand or like it and am already planning on switching my major to something I do enjoy and understand.

    I dont understand what you meant for satisfying the constructor. (the int a; int b; ) because I didn't type a Circle C = new Circle.

    I see Public Circle (int newRadius, int newCircumfrence) in the top part and Circle circ = new circle() on the bottom part.

    Sorry not trying to annoy or anything but I really picked the wrong thing for me to try.


    EDIT: Hold on, I got it. Thanks for help.
    Last edited by Promisha; 03-30-2011 at 01:50 AM.

  9. #9
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    It's not that hard, you can definitely understand it just google constructors and you should get a decent understanding. You need to code a new constructor which does not take any arguments or supply two arguments to the constructor at the bottom.

  10. #10
    Solarsonic is offline Senior Member
    Join Date
    Mar 2011
    Posts
    261
    Rep Power
    4

    Wink

    Quote Originally Posted by Promisha View Post
    Still can't get it to work. We just barely talked about OOP last class and I'm just confused. I just want exactly what I need to do to get this to work. I just wanted to try programming and I don't really understand or like it and am already planning on switching my major to something I do enjoy and understand.

    I dont understand what you meant for satisfying the constructor. (the int a; int b; ) because I didn't type a Circle C = new Circle.

    I see Public Circle (int newRadius, int newCircumfrence) in the top part and Circle circ = new circle() on the bottom part.

    Sorry not trying to annoy or anything but I really picked the wrong thing for me to try.


    EDIT: Hold on, I got it. Thanks for help.
    Your welcome. If you have any more problems feel free to post.

  11. #11
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,759
    Rep Power
    7

    Default

    Actually researching parameters would more help as the same problem will be encountered when they use methods.

Similar Threads

  1. Cannot find symbol
    By Johanis in forum New To Java
    Replies: 19
    Last Post: 11-04-2010, 08:13 PM
  2. Cannot find symbol
    By SarahB in forum New To Java
    Replies: 0
    Last Post: 03-06-2010, 03:03 PM
  3. Can not find symbol ???
    By AliceNewbie in forum New To Java
    Replies: 1
    Last Post: 02-17-2010, 01:44 AM
  4. Replies: 9
    Last Post: 10-18-2008, 08:26 PM
  5. Replies: 3
    Last Post: 05-01-2008, 08:30 AM

Posting Permissions

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