Results 1 to 4 of 4
Thread: Missing a constructor?
- 10-22-2008, 04:16 AM #1
Member
- Join Date
- Oct 2008
- Posts
- 2
- Rep Power
- 0
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;
}
-
perhaps you need a constructor that has all three parameters -- xPos, yPos and radius? Do you have the full assignment instructions available to post?
- 10-23-2008, 01:29 PM #3
Member
- Join Date
- Oct 2008
- Posts
- 2
- Rep Power
- 0
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
- 10-24-2008, 10:55 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
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
-
Missing text encoding
By talgreen in forum EclipseReplies: 0Last Post: 03-30-2008, 08:14 PM -
IOExceptions and missing JavaDoc
By tim in forum NetBeansReplies: 0Last Post: 01-29-2008, 12:55 PM -
Calling constructor of parent class from a constructor
By Java Tip in forum Java TipReplies: 0Last Post: 12-19-2007, 09:10 AM -
Calling constructor of same class from a constructor
By Java Tip in forum Java TipReplies: 0Last Post: 12-19-2007, 09:01 AM -
is it bug? or am i missing a point?
By blowguy in forum Threads and SynchronizationReplies: 1Last Post: 11-20-2007, 06:19 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks