Free Essay

It104 Project Battleship

In:

Submitted By katchme
Words 309
Pages 2
IT104 Project Battleship

Module secret () for space = 1 to 100 Display " " End for

Module fire (ammo, locTarget, playerLoc, player) Declare shot = call calcShot (playerLoc) Declare ammo = call ammo -1 If ammo 0 Then Declare shotDirLoc = playerLoc - 100 Else Display " " Display " There was an error in the program. " Declare exit = call exitProg () return shotDirLoc
End If

Module movePos (playerLoc, feet) Declare movement = call playerLoc + feet return movement
End module (movePos)

Module moveNeg (playerLoc, feet) Declare movement = call playerLoc - feet return movement
End module (moveNeg)

Module menu (playerName) Declare choice = call 0
WHILE choice == 0 Display "It is your turn" Display "1 -Fire Weapon\n2 -Advance Forward\ n3 -Retreat Back\n4 -Exit"
Try Then choice = "What do you want to do?" If choice > 0 and choice < 5 Then return choice
Else
Display " " Display " That was not an acceptable choice. Please try again." Display " " return choice = 0
Except Then Display " " Display " That was not an acceptable selection. Please try again." Display " "
Else Then choice = 0
End WHILE
Module exitProg () Display " Yes or No" Declare true = " Do you wish to leave the game?" If true = ="y" or == "Y" or == "yes" or =="Yes" Then
End If Else If true== "n" or == "N" or == "no" or == "NO" Then playAgain() Else Display " " Display "Error: Invalid Selection." Display " " playAgain () Except Then Display " " Display " Error: Invalid selection." Display " "
End playAgain ()

Module playAgain () Display "Yes or No"
Display " Yes or No" Declare true = " Do you wish to leave the game?" If true = ="y" or == "Y" or == "yes" or =="Yes" Then
End If Else If true== "n" or == "N" or == "no" or == "NO" Then exit Prog() Else Display " " Display "Error: Invalid Selection." Display " " exitProg () Except Then Display " " Display " Error: Invalid selection." Display " "

Module winner (player) Display player, " is the WINNER!!!!!!"
End module exitProg ()

Module main () Set choice = 0 Set ammo1 = 5 Set ammo2 = 5 Set feet = 0 Set nothing = 0

Similar Documents