Question: Hi, I have a basic Java question related to helper methods. Effectively I have 2 shapes. The first of which is a triangle. The X

Hi, I have a basic Java question related to helper methods.

Effectively I have 2 shapes. The first of which is a triangle. The X and Y position of said triangle are given as variables set in a constructor for a shape (HOUSE). I am using the triangle as the roof and a square as the body of said House.

this.roof.setXPos(50); this.roof.setYPos(300);

//sets the body relative to the roof, using the helper methods this.body.setXPos(getBodyXPos()); this.body.setYPos(getBodyYPos()

Specifically I want to write the helper methods for the above, but how do I go about correctly using a returned int from the getBodyXPOS() method?

I've compiled it using a stub entry of:

private int getBodyXPos() { //helper method to be written here. return 0; }

What can i do to keep the code very basic?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!