Using if statements
<p>In this program, the user will be asked to input 2 words, (firstWord and secondWord). The two words will automatically appear on the screen once the object is created. </p>

<p>firstWord is set to change its position on the screen via a while loop.</p>

<p>secondWord will stay in a fixed position.</p>

<p>I want the loop to end once the X position or Y position of firstWord is the same as secondWord.</p>

<p>The XY position of secondWord = (155, 361)</p>

<p>So for instance, something like:</p>

<pre><code>if (word1.xPosition = 155) {
    break;
}
</code></pre>

<p>Obviously, that code is wrong, it is just to give you
an idea of what I want to achieve.<br>
So how would I write this if statement?</p>

<p>My code is pasted below:</p>

<pre><code>public words(String w1, String w2)
{
    // initialise instance variables
    firstWord = new Text(w1);
    firstWord.randomizePosition();
    firstWord.changeColor("green");
    firstWord.changeSize(48);
    firstWord.makeVisible();
    secondWord = new Text(w2);
    secondWord.setPosition(155, 361);
    secondWord.changeColor("orange");
    secondWord.changeSize(48);
    secondWord.makeVisible();



public void draw()
{
   while(true) {

    firstWord.randomizePosition();

}    
    if(firstWord.xPosition =  ){

    break;    

}

}
</code></pre>

<p>Replace the if statement</p>