Advertisement
George_Nikou

Hangman game

Oct 14th, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. Sub Main()
  2. Dim c1 = New Car()
  3. Dim c2 = New Car("Toyota", "Matrix", "Red", 2006, 2000)
  4.  
  5. c1.Make = "Audi"
  6. c1.Model = "RS3"
  7. c1.Color = "New York Taxi Cab Yellow"
  8. c1.Year = 2019
  9. c1.Price = 63000
  10.  
  11. Console.WriteLine(c1.Make)
  12. Console.WriteLine(c2.Model)
  13. Console.WriteLine("Car 1: " & c1.desc)
  14. Console.WriteLine("Car 2: " & c2.desc)
  15.  
  16. c1.versus(c2)
  17.  
  18.  
  19.  
  20.  
  21. Dim word = "GEORGE"
  22. Dim lbl = ""
  23. Dim done As Boolean = False
  24. Dim guessed As New ArrayList()
  25.  
  26. For Each c As Char In word
  27. lbl &= "_"
  28. Next
  29. Console.WriteLine("Guess: " & lbl)
  30.  
  31.  
  32. Do While Not done
  33.  
  34. Console.Write("Guess a letter : ")
  35. Dim guess = Console.ReadLine()
  36.  
  37. Console.Write("Guessed : " & guess)
  38.  
  39. lbl = ""
  40. For Each c As Char In word
  41. If c = guess.ToUpper() Then
  42. lbl &= guess.ToUpper()
  43. guessed.Add(c)
  44. ElseIf guessed.IndexOf(c) >= 0 Then
  45. lbl &= c.ToString().ToUpper()
  46. Else
  47. lbl &= "_"
  48. End If
  49. Next
  50.  
  51. Console.WriteLine(vbNewLine & "Guess: " & lbl)
  52.  
  53. If (lbl = word) Then
  54. done = True
  55. Console.WriteLine("Congrats")
  56. End If
  57.  
  58. Loop
  59. Console.Read()
  60. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement