Results 1 to 6 of 6

Thread: simple question

  1. #1
    agater is offline Member
    Join Date
    Jul 2011
    Posts
    12
    Rep Power
    0

    Default 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.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: simple question

    what did they mean by " to given values. "
    I would assume that they mean the values that are "given" in the call to the constructor: new Circle(12, 12, 12);
    Here 12 would be the given values.
    That would be instead of the program having hardcoded values set by the programmer that it used.

  3. #3
    xlomo is offline Member
    Join Date
    Dec 2010
    Posts
    19
    Rep Power
    0

    Default Re: simple question

    x, and y define the point of the circle center and the radius the size of the circle.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default 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?

  5. #5
    xlomo is offline Member
    Join Date
    Dec 2010
    Posts
    19
    Rep Power
    0

    Default Re: simple question

    yes, right, well in that case shouldn't he write X=x instead of X = ax ?

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

    Default 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

  1. Simple question
    By Qsc in forum New To Java
    Replies: 6
    Last Post: 03-06-2011, 11:24 PM
  2. Simple Question
    By stackptr89 in forum New To Java
    Replies: 13
    Last Post: 01-29-2011, 05:35 PM
  3. some simple question?
    By jperson in forum New To Java
    Replies: 4
    Last Post: 05-03-2010, 05:32 PM
  4. Simple Question
    By barusk in forum Networking
    Replies: 13
    Last Post: 03-04-2009, 07:33 PM
  5. Probably a really simple question...
    By ibanez270dx in forum New To Java
    Replies: 0
    Last Post: 11-16-2007, 01:27 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
  •