Results 1 to 4 of 4
  1. #1
    kenny607 is offline Member
    Join Date
    Oct 2008
    Posts
    2
    Rep Power
    0

    Default Missing a constructor?

    Had to Create a circle My professor keeps rejecting what I wrote below saying that I'm missing my constructor. I don't see it.

    public class Circle {

    // Variables
    private double xPos;
    private double yPos;
    private double radius;

    // Constants
    static final int up = 1;
    static final int down = 2;
    static final int left = 3;
    static final int right = 4;

    public Circle(){

    }
    public Circle(double r){
    radius = r;
    }
    public Circle(double x, double y){
    xPos=x;
    yPos=y;
    }
    public double getX(){
    return xPos;
    }


    public double getY(){
    return yPos;
    }

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

    Default

    perhaps you need a constructor that has all three parameters -- xPos, yPos and radius? Do you have the full assignment instructions available to post?

  3. #3
    kenny607 is offline Member
    Join Date
    Oct 2008
    Posts
    2
    Rep Power
    0

    Default

    the assignemt was pretty open ended
    Create a constructor to accept the x and y position and the radius of the circle and construct a Circle

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

    Default

    So you need another overloaded constructor as follows.

    Java Code:
    public Circle(double x, double y, double r) {
        xPos = x;
        yPos = y;
        radius = r;
    }

Similar Threads

  1. Missing text encoding
    By talgreen in forum Eclipse
    Replies: 0
    Last Post: 03-30-2008, 08:14 PM
  2. IOExceptions and missing JavaDoc
    By tim in forum NetBeans
    Replies: 0
    Last Post: 01-29-2008, 12:55 PM
  3. Replies: 0
    Last Post: 12-19-2007, 09:10 AM
  4. Replies: 0
    Last Post: 12-19-2007, 09:01 AM
  5. is it bug? or am i missing a point?
    By blowguy in forum Threads and Synchronization
    Replies: 1
    Last Post: 11-20-2007, 06:19 PM

Posting Permissions

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