Thursday 2 May 2013

Functions

As discussed with other members, we find that few functions should be used in this program .

SNAKE ( ) ---->  will have 3 questions . The question will be randomly choose using srand as the player reaches this specific level . If the player fails to answer the question the level of the player will be reduced accordingly .

LADDER ( ) -----> will have 3 questions . The question will be randomly choose using srand as the player reaches this specific level . If the player fails to answer the question the level of the player will be remained accordingly . Else, the level will be increased .

DICE ( ) ------>Player will literally roll the dice by enter any number . We use srand function to randomly choose number from 1 to 6 for the player by using formula : randNo = 1 + rand( ) % (6-1+1) . The random number is actually the level of the player and will be sum up on the next dice roll .

ACTIONX( ) -----> This function is to indicate whether there's snake or ladder at particular level for player 1 .


ACTIONY( ) -----> This function is to indicate whether there's snake or ladder at particular level for player 2 .

GREETX ( ) -------> This function will calculate the current level of player 1 as dice rolled .

GREETY ( ) -------> This function will calculate the current level of player 2 as dice rolled .

LAYOUT ( ) -------> To display the layout of the snake and ladder board.








No comments:

Post a Comment