Advertisement
Guest User

Untitled

a guest
Nov 15th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.25 KB | None | 0 0
  1. Module Module1
  2.  
  3.     Sub Main()
  4.         Console.WriteLine("--------------Chutes & Ladders--------------")
  5.         Console.WriteLine("Press Enter to start!")
  6.         Console.ReadLine()
  7.  
  8.  
  9.         Dim gameboard() As Integer = getInputs(True, generateBoard())
  10.  
  11.         Console.WriteLine(showBoard(gameboard))
  12.  
  13.     End Sub
  14.  
  15.     Function generateBoard() As Integer()
  16.         Dim gameBoard(100) As Integer
  17.  
  18.         For i = 0 To 99
  19.             gameBoard(i) = 0
  20.         Next
  21.  
  22.         Return gameBoard
  23.     End Function
  24.  
  25.     Function getInputs(Type As Boolean, gameBoard As Integer()) As Integer()
  26.         Dim word As String
  27.         Dim startPoint As Integer
  28.         Dim movementSize As Integer
  29.  
  30.  
  31.         If Type Then
  32.             word = " Chute "
  33.         Else
  34.             word = " Ladder "
  35.         End If
  36.  
  37.         For i = 1 To 10
  38.             Console.WriteLine("Enter start position for" & word & i & ":")
  39.             Console.ReadLine()
  40.  
  41.             While gameBoard(startPoint) <> 0
  42.                 Console.WriteLine("There is already a Chute or Ladder in this place!")
  43.                 Console.WriteLine("Enter start position for" & word & i & ":")
  44.                 Console.ReadLine()
  45.             End While
  46.  
  47.             If Type Then
  48.                 While startPoint < 10
  49.                     Console.WriteLine("Start point must be at least 10!")
  50.                     Console.WriteLine("Enter start position for" & word & i & ":")
  51.                     Console.ReadLine()
  52.                 End While
  53.             Else
  54.                 While startPoint > 90
  55.                     Console.WriteLine("Start point must be at lower than 90!")
  56.                     Console.WriteLine("Enter start position for" & word & i & ":")
  57.                     Console.ReadLine()
  58.                 End While
  59.             End If
  60.  
  61.             Console.WriteLine("Enter how many spaces the player should move (10-30)")
  62.             movementSize = Console.ReadLine
  63.  
  64.             While movementSize < 10 And movementSize > 30
  65.                 Console.WriteLine("Please enter a number between 10 and 30!")
  66.                 Console.WriteLine("Enter how many spaces the player should move (10-30)")
  67.                 Console.ReadLine()
  68.             End While
  69.  
  70.             If Type Then
  71.                 While startPoint - movementSize < 0
  72.                     Console.WriteLine("This would send them out of bounds!")
  73.                     Console.WriteLine("Enter how many spaces the player should move")
  74.                     Console.ReadLine()
  75.                 End While
  76.             Else
  77.                 While startPoint + movementSize > 99
  78.                     Console.WriteLine("This would send them out of bounds!")
  79.                     Console.WriteLine("Enter how many spaces the player should move")
  80.                     Console.ReadLine()
  81.                 End While
  82.             End If
  83.         Next
  84.  
  85.         If Type Then
  86.             getInputs(False, gameBoard)
  87.         End If
  88.  
  89.         Return gameBoard
  90.     End Function
  91.  
  92.     Function showBoard(gameBoard As Integer())
  93.         Dim board As String = ""
  94.         board = board & "["
  95.         For i = 0 To 99
  96.             board = board & gameBoard(i) & ", "
  97.         Next
  98.  
  99.         board = board & "]"
  100.  
  101.         Return board
  102.     End Function
  103.  
  104. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement