Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports Microsoft.VisualBasic.VBMath
- Module Module1
- Sub Main()
- Console.WriteLine("Witaj, w ktora wersje gry chcesz zagrac? easy / normal?")
- Menu()
- End Sub
- Sub Menu()
- Dim opt As String = Console.ReadLine
- If opt = "easy" Then
- Console.Clear()
- Easy()
- ElseIf opt = "normal" Then
- Console.Clear()
- Normal()
- Else
- Console.Clear()
- Console.WriteLine("Zla wersja gry (" & opt & ")! Uzyj 'easy' lub 'normal'!")
- Menu()
- End If
- End Sub
- 'Tryb easy
- Sub Easy()
- 'Generowanie losowej liczby od 1 do 100
- Dim randomValue As String = CInt(Math.Floor((100 - 1 + 1) * Rnd())) + 1
- Console.WriteLine("Wlasnie wymyslilem liczbe od 1 do 100! Zgadnij jaka to liczba!")
- Dim inp As String
- 'Loop odpowiadajacy za pobieranie wpisywanych liczb do czasu kiedy nie wpiszemy wlasciwej
- Do Until inp = randomValue
- Console.Write("Podaj liczbe: ")
- inp = Console.ReadLine
- Console.Clear()
- If inp > randomValue Then
- Console.WriteLine("Podana liczba jest za duza! Sproboj ponownie!")
- ElseIf inp < randomValue Then
- Console.WriteLine("Podana liczba jest za mala! Sproboj ponownie!")
- End If
- Loop
- 'Gdy loop sie zakonczy znaczy ze zgadlismy i wtedy wykonywana jest dalsza czesc kodu
- Console.WriteLine("Zgadles, brawo! Prawidlowa liczba: " & randomValue)
- Console.Write("Gramy ponownie? (tak / nie): ")
- Dim gramyponownie As String = Console.ReadLine
- If gramyponownie = "tak" Then
- Normal()
- Else
- Exit Sub
- End If
- End Sub
- 'Tryb latwy, kod dziala tak samo jak w powyzszym przykladzie
- Sub Normal()
- Dim randomValue As String = CInt(Math.Floor((100 - 1 + 1) * Rnd())) + 1
- Console.WriteLine("Wlasnie wymyslilem liczbe od 1 do 100! Zgadnij jaka to liczba!")
- Dim inp As String
- Do Until inp = randomValue
- Console.Write("Podaj liczbe: ")
- inp = Console.ReadLine
- Console.Clear()
- If Not inp = randomValue Then
- Console.WriteLine("Zla liczba! Sproboj ponownie!")
- End If
- Loop
- Console.WriteLine("Zgadles, brawo! Prawidlowa liczba: " & randomValue)
- Console.Write("Gramy ponownie? (tak / nie): ")
- Dim gramyponownie As String = Console.ReadLine
- If gramyponownie = "tak" Then
- Normal()
- Else
- Exit Sub
- End If
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement