Note that there are some explanatory texts on larger screens.

plurals
  1. POCompleting some simple methods
    primarykey
    data
    text
    <p>trying to complete some methods, which I think should be straight forward for someone with a bit of experience in Java. I'm a total noob :)</p> <p><strong>Complete the method setXPosShark() which sets the x-position of the shark to the method's int arguement.</strong></p> <pre><code> /** * Sets the x-position of the shark to the value of the argument */ public void setXPosShark(int x) { // to be completed for part(i) } </code></pre> <p>Would this be:</p> <pre><code> shark.setXPos(x); </code></pre> <p>?</p> <p><strong>Complete the method setXPosSwimmer() which sets the x-position of the legs of the swimmer to the arguement x, the x-position of the body to x plus 10 and the x-position of the head to x plus 46.</strong></p> <pre><code> /** * Sets the x-position of each of the legs, body and head of the swimmer. * The x position of the legs is set to the argument, the x position of * the body is set to the argument plus 10, and the x position of the * head is set to the argument plus 46. */ public void setXPosSwimmer(int x) { // to be completed for part(ii) } </code></pre> <p><strong>Complete the method sinkSwimmer(). The method should move each component (head, body and legs) of the swimmer down by 50 units, and make the colour of each component blue.</strong> (</p> <pre><code> /** * Makes the swimmer appear to disappear by increasing the * y-position of each of the head, body and legs by 50, and * turning their colour blue. */ public void sinkSwimmer() { //to be completed for part(iii) } </code></pre> <p><strong>Complete the method moveSimmer() which causes the compnents of the swimmer to move one unit to the right of their current positions.</strong></p> <pre><code> /** * Causes the swimmer to move one unit to the right of its current position. */ public void moveSwimmer() { // to be completed for part(iv) } </code></pre> <p>Massive thank you to anyone that can help. I am working all through the nighht to try and complete an informal assignment (i.e. it is not graded) so that I can get the feedback returned before an upcoming assignment. Thanks, Ali</p> <p>EDIT My guesses are</p> <p>For the second one: </p> <pre><code> this.leg.setPosition(x); this.body.setPosition(x+10); this.head.setPosition(x+46); </code></pre> <p>Third one: </p> <pre><code> this.legs.setPosition(y-50); this.body.setPosition(y-50); this.head.setPosition(y-50); </code></pre> <p>Fourth: </p> <pre><code> this.legs.(this.legs() ); </code></pre> <p>Not too sure about this one at all.</p> <p>Here is a pastebin link to the full code I am working with (rather large): <a href="http://pastebin.com/mF06jjSv" rel="nofollow">http://pastebin.com/mF06jjSv</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload