Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Module Module1
- Sub Main()
- Console.WriteLine("--------------Chutes & Ladders--------------")
- Console.WriteLine("Press Enter to start!")
- Console.ReadLine()
- Dim gameboard() As Integer = getInputs(True, generateBoard())
- Console.WriteLine(showBoard(gameboard))
- End Sub
- Function generateBoard() As Integer()
- Dim gameBoard(100) As Integer
- For i = 0 To 99
- gameBoard(i) = 0
- Next
- Return gameBoard
- End Function
- Function getInputs(Type As Boolean, gameBoard As Integer()) As Integer()
- Dim word As String
- Dim startPoint As Integer
- Dim movementSize As Integer
- If Type Then
- word = " Chute "
- Else
- word = " Ladder "
- End If
- For i = 1 To 10
- Console.WriteLine("Enter start position for" & word & i & ":")
- Console.ReadLine()
- While gameBoard(startPoint) <> 0
- Console.WriteLine("There is already a Chute or Ladder in this place!")
- Console.WriteLine("Enter start position for" & word & i & ":")
- Console.ReadLine()
- End While
- If Type Then
- While startPoint < 10
- Console.WriteLine("Start point must be at least 10!")
- Console.WriteLine("Enter start position for" & word & i & ":")
- Console.ReadLine()
- End While
- Else
- While startPoint > 90
- Console.WriteLine("Start point must be at lower than 90!")
- Console.WriteLine("Enter start position for" & word & i & ":")
- Console.ReadLine()
- End While
- End If
- Console.WriteLine("Enter how many spaces the player should move (10-30)")
- movementSize = Console.ReadLine
- While movementSize < 10 And movementSize > 30
- Console.WriteLine("Please enter a number between 10 and 30!")
- Console.WriteLine("Enter how many spaces the player should move (10-30)")
- Console.ReadLine()
- End While
- If Type Then
- While startPoint - movementSize < 0
- Console.WriteLine("This would send them out of bounds!")
- Console.WriteLine("Enter how many spaces the player should move")
- Console.ReadLine()
- End While
- Else
- While startPoint + movementSize > 99
- Console.WriteLine("This would send them out of bounds!")
- Console.WriteLine("Enter how many spaces the player should move")
- Console.ReadLine()
- End While
- End If
- Next
- If Type Then
- getInputs(False, gameBoard)
- End If
- Return gameBoard
- End Function
- Function showBoard(gameBoard As Integer())
- Dim board As String = ""
- board = board & "["
- For i = 0 To 99
- board = board & gameBoard(i) & ", "
- Next
- board = board & "]"
- Return board
- End Function
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement