Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8226337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:43:42+00:00 2026-06-07T15:43:42+00:00

Inside the Person Class: public Point[] endPointArray; private int scalar; private Head head; private

  • 0

Inside the Person Class:

  public Point[] endPointArray;
  private int scalar;
  private Head head;
  private Neck neck;

  public Person(){
    scalar = 1;
    endPointArray = new Point[100];
    for ( int i = 0 ; i < 100 ; i++ ){
      endPointArray[i] = new Point();
    }
    positionArray = new int[4];
    point = new Point(0,0);
    endPointArray[0].x = 5;
    endPointArray[0].y = 5;

    head = new Head(neck, endPointArray, scalar);
    neck = new Neck(body, endPointArray, scalar);
  }

  public void draw(Graphics g){
    head.draw(g);
    neck.draw(g);
  }

Inside the Head Class:

// ---------- CONSTANTS. ----------
  private static int Base_Radius = 20;

  // ---------- VARIABLE DECLARATIONS. ----------
  private int radius;
  private int scale; // Scale determines how large the Head will be.
  private Point startingPoint; //Starting Point for the Person and the Head.
  private Point endingPoint; //Ending Point, where the Neck will start from.
  private Point[] endPointArray; // Contains startingPoint in position [0] by this point from Person.
  private Point centre;
  private Neck neck;

  // ----------------------------------------
  // HEAD CREATION.
  // ----------------------------------------
  public Head(Neck neck, Point[] endPointArray, int scale){

    this.neck = neck;
    this.endPointArray = endPointArray;
    this.scale = scale;

    radius = Base_Radius * scale;
    startingPoint = new Point();
    endingPoint = new Point();
    centre = new Point();

    // Copies the value of endPointArray[0] into startingPoint.
    startingPoint.x = endPointArray[0].x;
    startingPoint.y = endPointArray[0].y;

    // Picks the point on the Head where the Neck will start from.
    endingPoint.x = startingPoint.x + radius;
    endingPoint.y = startingPoint.y + ( 2*radius );

    // Assigns the value of the circles centre to the centre point.
    centre.x = startingPoint.x + radius;
    centre.y = startingPoint.y + radius;
    // Puts the value of the endingPoint into the endPointArray[1].
    endPointArray[1].x = endingPoint.x;
    endPointArray[1].y = endingPoint.y;
  }

  // ----------------------------------------
  // DRAW THE HEAD.
  // ----------------------------------------
  public void draw(Graphics g){
    g.drawOval(startingPoint.x, startingPoint.y, radius, radius);
    System.out.println("Radius : " + radius);
    System.out.println("Head Starting Point : ("+startingPoint.x+","+startingPoint.y+").");
    System.out.println("Head Ending Point : ("+endingPoint.x+","+endingPoint.y+").\n");
  }

Inside the Neck Class:

// ---------- CONSTANTS. ----------
 private static int Base_Length = 10;

 // ---------- VARIABLE DECLARATIONS. ----------
 private int length;
 private int scale; // Scale determines how large the Head will be.
 private Point anglePoint;
 private Point startingPoint; //Starting Point for the Person and the Head.
 private Point endingPoint; //Ending Point, where the Neck will start from.
 private Point[] endPointArray; // Contains startingPoint in position [0] by this point from Person.
 private Body body;

 // ----------------------------------------
 // NECK CREATION.
 // ----------------------------------------
 public Neck(Body body, Point[] endPointArray, int scale){

  this.endPointArray = endPointArray;
  this.body = body;
  this.scale = scale;

  length = Base_Length * scale;
  startingPoint = new Point();
  endingPoint = new Point();
  anglePoint = new Point();

  // Making the startingPoint equal to the endPointArray[1].
  startingPoint.x = endPointArray[1].x;
  startingPoint.y = endPointArray[1].y;

  // Seting the values of the point where the neck finishes.
  endingPoint.x = startingPoint.x;
  endingPoint.y = startingPoint.y + length;

 }

 // ----------------------------------------
 // DRAW THE HEAD.
 // ----------------------------------------
 public void draw(Graphics g){
    g.drawLine(startingPoint.x, startingPoint.y, endingPoint.x, endingPoint.y);
    System.out.println("Neck Starting Point : ("+startingPoint.x+","+startingPoint.y+").");
    System.out.println("Neck Ending Point : ("+endingPoint.x+","+endingPoint.y+").");
  }

Output:

Radius : 20

Head Starting Point : (5,5).

Head Ending Point : (25,45).

Neck Starting Point : (25,45).

Neck Ending Point : (25,55).

The Head is drawn in the Panel at 5,5 and seems to have the right radius. The neck is floating apart from the head a way away from it. The output seems to look right, but visually it is incorrect. The neck is supposed to be a horizontal line downwards from the base of the head and I don’t know why it isn’t behaving the way I expect it to.
Sorry if this is a newbie question but I am quite stuck at the moment.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:43:43+00:00Added an answer on June 7, 2026 at 3:43 pm

    The problem is that drawOval takes width and height as parameters but you’re passing in the radius. You need to use:

    g.drawOval(startingPoint.x, startingPoint.y, 2 * radius, 2 * radius);
    

    From the API:

    public abstract void drawOval(int x, int y, int width, int height)
        Draws the outline of an oval. The result is a circle or ellipse that fits within the rectangle specified by the x, y, width, and height arguments.
        The oval covers an area that is width + 1 pixels wide and height + 1 pixels tall.
    
    Parameters:
        x - the x coordinate of the upper left corner of the oval to be drawn.
        y - the y coordinate of the upper left corner of the oval to be drawn.
        width - the width of the oval to be drawn.
        height - the height of the oval to be drawn.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of Persons inside a Company Class. public class Company{ IList<Person>
I'm using Gson API and created a class like: public class Person { private
This is the simplified model : public class Person { public int Id; public
class Bob extends Person { //do some stuff } class Person { public function
(Java Spring WebApp) I have: public class PersonValidator implements Validator { private PersonDAO d;
I have a class : public class Person { public string name { get;
for sake of simplicity: public class Person { String name; Set<Address> addresses; } public
Say I have ViewModel class MyViewModel like: public class MyViewModel : ViewModelBase { private
I've been trying to use a List<> of a Model.Person that I have inside
Is it possible to get the class type from inside the static initialization block?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.