Advertisement
Metexu

M3Dla Michala

Nov 16th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports Microsoft.VisualBasic.VBMath
  2. Module Module1
  3.  
  4.     Sub Main()
  5.         Console.WriteLine("Witaj, w ktora wersje gry chcesz zagrac? easy / normal?")
  6.         Menu()
  7.     End Sub
  8.  
  9.     Sub Menu()
  10.         Dim opt As String = Console.ReadLine
  11.         If opt = "easy" Then
  12.             Console.Clear()
  13.             Easy()
  14.         ElseIf opt = "normal" Then
  15.             Console.Clear()
  16.             Normal()
  17.         Else
  18.             Console.Clear()
  19.             Console.WriteLine("Zla wersja gry (" & opt & ")! Uzyj 'easy' lub 'normal'!")
  20.             Menu()
  21.         End If
  22.     End Sub
  23.  
  24.     'Tryb easy
  25.    Sub Easy()
  26.         'Generowanie losowej liczby od 1 do 100
  27.        Dim randomValue As String = CInt(Math.Floor((100 - 1 + 1) * Rnd())) + 1
  28.  
  29.  
  30.  
  31.         Console.WriteLine("Wlasnie wymyslilem liczbe od 1 do 100! Zgadnij jaka to liczba!")
  32.         Dim inp As String
  33.  
  34.  
  35.         'Loop odpowiadajacy za pobieranie wpisywanych liczb do czasu kiedy nie wpiszemy wlasciwej
  36.        Do Until inp = randomValue
  37.  
  38.  
  39.  
  40.             Console.Write("Podaj liczbe: ")
  41.             inp = Console.ReadLine
  42.             Console.Clear()
  43.  
  44.  
  45.  
  46.             If inp > randomValue Then
  47.                 Console.WriteLine("Podana liczba jest za duza! Sproboj ponownie!")
  48.             ElseIf inp < randomValue Then
  49.                 Console.WriteLine("Podana liczba jest za mala! Sproboj ponownie!")
  50.             End If
  51.  
  52.  
  53.  
  54.         Loop
  55.  
  56.  
  57.         'Gdy loop sie zakonczy znaczy ze zgadlismy i wtedy wykonywana jest dalsza czesc kodu
  58.        Console.WriteLine("Zgadles, brawo! Prawidlowa liczba: " & randomValue)
  59.         Console.Write("Gramy ponownie? (tak / nie): ")
  60.         Dim gramyponownie As String = Console.ReadLine
  61.         If gramyponownie = "tak" Then
  62.             Normal()
  63.         Else
  64.             Exit Sub
  65.         End If
  66.     End Sub
  67.  
  68.  
  69.     'Tryb latwy, kod dziala tak samo jak w powyzszym przykladzie
  70.    Sub Normal()
  71.  
  72.  
  73.  
  74.         Dim randomValue As String = CInt(Math.Floor((100 - 1 + 1) * Rnd())) + 1
  75.         Console.WriteLine("Wlasnie wymyslilem liczbe od 1 do 100! Zgadnij jaka to liczba!")
  76.         Dim inp As String
  77.  
  78.  
  79.  
  80.         Do Until inp = randomValue
  81.             Console.Write("Podaj liczbe: ")
  82.             inp = Console.ReadLine
  83.             Console.Clear()
  84.             If Not inp = randomValue Then
  85.                 Console.WriteLine("Zla liczba! Sproboj ponownie!")
  86.             End If
  87.         Loop
  88.  
  89.  
  90.  
  91.         Console.WriteLine("Zgadles, brawo! Prawidlowa liczba: " & randomValue)
  92.         Console.Write("Gramy ponownie? (tak / nie): ")
  93.         Dim gramyponownie As String = Console.ReadLine
  94.         If gramyponownie = "tak" Then
  95.             Normal()
  96.         Else
  97.             Exit Sub
  98.         End If
  99.  
  100.  
  101.  
  102.     End Sub
  103.  
  104.  
  105.  
  106. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement