Results 1 to 6 of 6
Thread: simple question
- 11-06-2011, 09:17 PM #1
Member
- Join Date
- Jul 2011
- Posts
- 12
- Rep Power
- 0
simple question
hey guys "
this is a part of a big qusion .( The class circle has a three-argument constructor that sets the values of x, y, and radius to given values. )
what did they mean by " to given values. "
I answered like this:
public Circle(int x, int y, int radius)
{
X = ax;
Y = ay;
Radius = aRadius;
}Last edited by agater; 11-06-2011 at 09:19 PM.
- 11-06-2011, 09:27 PM #2
Re: simple question
I would assume that they mean the values that are "given" in the call to the constructor: new Circle(12, 12, 12);what did they mean by " to given values. "
Here 12 would be the given values.
That would be instead of the program having hardcoded values set by the programmer that it used.
- 11-06-2011, 10:00 PM #3
Member
- Join Date
- Dec 2010
- Posts
- 19
- Rep Power
- 0
Re: simple question
x, and y define the point of the circle center and the radius the size of the circle.
- 11-06-2011, 10:02 PM #4
Re: simple question
Yes, that makes sense. The question is: How are those three variables given values?
Are they given by the user of the class
or are they set by the programmer?
- 11-07-2011, 02:19 AM #5
Member
- Join Date
- Dec 2010
- Posts
- 19
- Rep Power
- 0
Re: simple question
yes, right, well in that case shouldn't he write X=x instead of X = ax ?
-
Re: simple question
To follow Java naming conventions the class fields should begin with lower case letters. So...
Java Code:class Foo { int x; public Foo(int x) { this.x = x; } }
Similar Threads
-
Simple question
By Qsc in forum New To JavaReplies: 6Last Post: 03-06-2011, 11:24 PM -
Simple Question
By stackptr89 in forum New To JavaReplies: 13Last Post: 01-29-2011, 05:35 PM -
some simple question?
By jperson in forum New To JavaReplies: 4Last Post: 05-03-2010, 05:32 PM -
Simple Question
By barusk in forum NetworkingReplies: 13Last Post: 03-04-2009, 07:33 PM -
Probably a really simple question...
By ibanez270dx in forum New To JavaReplies: 0Last Post: 11-16-2007, 01:27 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks