# Text box of points Nr. 2

Hello again,

I have this task. It is in german:

Schreiben Sie die FunkQon makeX() mit dem Parameter size.
Ihre FunkQon sollte einen (Text-)Kasten der entsprechenden Höhe und Breite zeichnen, bestehend aus
Punkten und Hash-Symbolen (#). Die #-Zeichen sollen dabei ein Kreuz bilden.
Testen Sie Ihre FunkQon mit folgendem Code:
void setup() {
makeX(5);
makeX(10);
}

![Bild2|192x290]

Now i tried it with this code:

``````void setup ()
{
makeX(5);
makeX(10);

}

void makeX(int n)
{
for(int z =0 ; z < n; z++)
{
for(int s = 0; s < n; s++)
{
if (s == z && s > z || z == s )
{
print("#");
}
else
{
print(".");
}
}

println();
}

}
``````

I am nearly finished.
I just need to make the line on the oder side.
I think I need to expand the if cause.

Could someone give me a hint for this example?

1 Like

1 Like

Your if statement’s expression is very strange.

`if (s == z && s > z || z == s )`

This says… if s equals z AND s is greater than z

Well, that’s already never going to be true, is it? s can’t equal z and be greater than z at the same time! So the first half of this expression is always false.

So what it really says is… if False OR z equals s…

But False is never going to satisfy the condition. So we can simplify it!
This is the same expression, without the useless first two thirds:

`if ( s == z ) `

Now, since you are drawing an X (which I can thankfully tell based on the function name), you draw one line for it when s and z are equal. What can you say about the relationship between s, z and n along the other line? (Hint: What can you say about n-s and z?)

1 Like

Ok I found it. Thank you for your help.

``````void setup ()
{
makeX(5);
makeX(10);
}

void makeX(int n)
{
for (int z =0; z < n; z++)
{
for (int s = 0; s < n; s++)
{
if (s == z || n - s == z+ 1 )
{
print("#");
} else
{
print(".");
}
}

println();
}
}
``````
2 Likes