Is this code correc...
 
Notifications
Clear all

Is this code correct?

armresl
(@armresl)
Community Legend

Someone made this up for a shirt which I guess is supposed to indicate
rack balls, break, run table.

The rest I assume is supposed to mean keep playing if they have money, is it written correctly?

o
{
rack_balls();
break();
run_table();
//} while (opponent_has_money());
} while (opponent[money] > 0 || opponent );

Quote
Topic starter Posted : 26/04/2020 12:24 am
athulin
(@athulin)
Community Legend

The rest I assume is supposed to mean keep playing if they have money, is it written correctly?

Don't think so. But it may be a question of what programming language is involved.

break();
Those I know insist that break is a reserved word. But I am out of touch with modern languages.

o
I can only assume it should be 'do'.

while (opponent[money] > 0 || opponent );
To my eyes that is check for 'while opponent has money, or if he hasn't any, if he exists at all.' It might be something else. Or it may be a reflection of deep philosophical issues. But if it was me, I'd use reverse the tests, and use an '&&' operator instead.

do
{
...
} while (opponent[money] > 0 || opponent );

plays a game before performing those checks. Each to his own, but I'd verify that before I started to play.

So perhaps something like


while (opponent && opponent[money] > 0) {
rack_balls();
break_off();
run_table();
}

Added … but given my personal skill at pool, a check for me[money] > 0 would probably be required…

ReplyQuote
Posted : 27/04/2020 11:29 am
Share: