Advertisement
Guest User

loool

a guest
Apr 2nd, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.29 KB | None | 0 0
  1. Module Module1
  2. Dim athletes(40) As athlete_login
  3. Dim admin(2) As admin_login
  4. Dim confirm As Char
  5. Dim athlete_counter As Integer = 0
  6. Dim login_counter As Integer = 0
  7. Dim training_type, user As String
  8. Dim speed, time, calburned, totalcal As Integer
  9. Dim login_path As String = "I:\running club\login.csv"
  10. Dim personal_details_path As String = "I:\running club\personal_details.csv"
  11. Dim training_record_path As String = "I:\running club\training_record.csv"
  12. Dim total As String = "I:\running club\training_total.csv"
  13. Structure admin_login
  14. Dim username, password As String
  15. End Structure
  16. Structure athlete_login
  17. Dim username, password, name As String
  18. End Structure
  19.  
  20. Sub Main()
  21. login_file()
  22. login()
  23. End Sub
  24. Sub login_file()
  25. FileOpen(1, login_path, OpenMode.Input)
  26. Do Until EOF(1)
  27. Dim line As String = LineInput(1)
  28. Dim temp() As String = Split(line, ",")
  29. If temp(2) = "ATHLETE" Then
  30. athletes(athlete_counter).username = temp(0)
  31. athletes(athlete_counter).password = temp(1)
  32. athletes(athlete_counter).name = temp(3)
  33. athlete_counter += 1
  34. Else
  35. admin(login_counter).username = temp(0)
  36. admin(login_counter).password = temp(1)
  37. login_counter += 1
  38. End If
  39. Loop
  40. FileClose(1)
  41. End Sub
  42. Sub login()
  43. Console.Clear()
  44. Console.WriteLine("Username:")
  45. Dim Username As String = Console.ReadLine
  46. Console.WriteLine("Password:")
  47. Dim Password As String = Console.ReadLine
  48. For i = 0 To athlete_counter - 1
  49. user = athletes(i).username
  50. If Username.ToLower = athletes(i).username.ToLower And Password = athletes(i).password Then
  51. athlete_menu()
  52. End If
  53. Next
  54. For i = 0 To login_counter - 1
  55. If Username.ToLower = admin(i).username.ToLower And Password = admin(i).password Then
  56. admin_menu()
  57. End If
  58. Next
  59. Console.ForegroundColor = ConsoleColor.Red
  60. Console.WriteLine("Invalid")
  61. Console.WriteLine("You will return to login menu in 3 seconds.")
  62. System.Threading.Thread.Sleep(3000)
  63. Console.ForegroundColor = ConsoleColor.White
  64. login()
  65. End Sub
  66. Sub admin_menu()
  67. Console.Clear()
  68. Console.ForegroundColor = ConsoleColor.Cyan
  69. Console.WriteLine("WELCOME TO ADMIN'S MENU")
  70. Console.ForegroundColor = ConsoleColor.White
  71. Console.WriteLine("1 -Add User")
  72. Console.WriteLine("2 -Delete User")
  73. Console.WriteLine("3- View Proggress")
  74. Console.WriteLine("4 -Log Out")
  75. Dim pick As Integer = Console.ReadLine()
  76. Select Case pick
  77. Case "1"
  78. add_user()
  79. Case "2"
  80. Delete_user()
  81. Case "3"
  82. training_progres()
  83. Case "4"
  84. Console.WriteLine("You will return to login menu in 3 seconds.")
  85. System.Threading.Thread.Sleep(3000)
  86. login()
  87. End Select
  88.  
  89.  
  90. End Sub
  91. Sub athlete_menu()
  92. Console.Clear()
  93. Console.ForegroundColor = ConsoleColor.Magenta
  94. Console.WriteLine("WELCOME TO ATHLETE'S MENU")
  95. Console.ForegroundColor = ConsoleColor.White
  96. Console.WriteLine("1 -Add Personal Details")
  97. Console.WriteLine("2 -Edit Personal Details")
  98. Console.WriteLine("3 -Add Training Record")
  99. Console.WriteLine("4 -View Training Proggress")
  100. Console.WriteLine("5 -Log Out")
  101. Dim pick As Integer = Console.ReadLine()
  102. Select Case pick
  103. Case "1"
  104. Add_Personal_Details()
  105. Case "2"
  106. Edit_Personal_Details()
  107. Case "3"
  108. Training_record()
  109. Case "4"
  110. training_progres()
  111. Case "5"
  112. Console.ForegroundColor = ConsoleColor.Red
  113. Console.WriteLine("You will return to login menu in 3 seconds.")
  114. Console.ForegroundColor = ConsoleColor.White
  115. System.Threading.Thread.Sleep(3000)
  116. login()
  117. End Select
  118. End Sub
  119. Sub Training_record()
  120. Console.Clear()
  121. Console.WriteLine("What training type you want to add?")
  122. Console.WriteLine("1 -Running")
  123. Console.WriteLine("2 -Cycling")
  124. Console.WriteLine("3 -Swiming")
  125. Console.WriteLine("4 -Return")
  126. Dim type As Integer = Console.ReadLine()
  127. Select Case type
  128. Case "1"
  129. running()
  130. Case "2"
  131. cycling()
  132. Case "3"
  133. swimming()
  134. Case "4"
  135. athlete_menu()
  136. End Select
  137. End Sub
  138. Sub running()
  139. Console.Clear()
  140. training_type = "Running"
  141. Console.WriteLine("What speed were you running with,between 5-10(mph)? ")
  142. speed = Console.ReadLine()
  143. Console.WriteLine("Please enter the amount of minutes you have been running.")
  144. time = Console.ReadLine()
  145.  
  146. If speed >= 5 And speed < 6 Then
  147. calburned = 472 / 60 * time
  148. ElseIf speed >= 6 And speed < 7 Then
  149. calburned = 590 / 60 * time
  150. ElseIf speed >= 7 And speed < 8 Then
  151. calburned = 679 / 60 * time
  152. ElseIf speed >= 8 And speed < 9 Then
  153. calburned = 797 / 60 * time
  154. ElseIf speed >= 9 And speed < 10 Then
  155. calburned = 885 / 60 * time
  156. ElseIf speed <= 10 Then
  157. calburned = 944 / 60 * time
  158. End If
  159. save()
  160. End Sub
  161. Sub cycling()
  162. Console.Clear()
  163. training_type = "Cycling"
  164. Console.WriteLine("What speed were you cycling with,between (mph)? ")
  165. speed = Console.ReadLine()
  166. Console.WriteLine("Please enter the amount of hours you have been cycling for.")
  167. time = Console.ReadLine()
  168. If speed > 10 Then
  169. calburned = 236 * time
  170. ElseIf speed >= 10 And speed < 12 Then
  171. calburned = 354 * time
  172. ElseIf speed >= 12 And speed < 14 Then
  173. calburned = 472 * time
  174. ElseIf speed >= 14 And speed < 16 Then
  175. calburned = 590 * time
  176. ElseIf speed >= 16 And speed < 20 Then
  177. calburned = 708 * time
  178. ElseIf speed < 20 Then
  179. calburned = 944 * time
  180. End If
  181. save()
  182. End Sub
  183. Sub swimming()
  184. Console.Clear()
  185. training_type = "Swimming"
  186. Console.WriteLine("Please enter the amount of hours you have been swimming for.")
  187. time = Console.ReadLine()
  188. Console.WriteLine("What style were you swimming with? ")
  189. Console.WriteLine("1 -Freestyle slow or Backstroke")
  190. Console.WriteLine("2- Freestyle fast or Breaststroke")
  191. Console.WriteLine("3 -Butterfly")
  192. confirm = Console.ReadLine()
  193. Select Case confirm
  194. Case "1"
  195. calburned = 413 * time
  196. save()
  197. Case "2"
  198. calburned = 590 * time
  199. save()
  200. Case "3"
  201. calburned = 649 * time
  202. save()
  203. End Select
  204. Console.ReadKey()
  205. End Sub
  206. Sub training_progres()
  207. Console.Clear()
  208. Dim FullLine As String = ""
  209. FileOpen(1, training_record_path, OpenMode.Input)
  210. Do Until EOF(1)
  211. FullLine = LineInput(1)
  212. Dim Item() As String = Split(FullLine, ",")
  213. Console.WriteLine("{0,-10} {1,-10} {2,15}", Item(0), Item(1), Item(2))
  214. 'Console.WriteLine("Username: " & Item(0))
  215. 'Console.WriteLine("Training Type: " & Item(1))
  216. 'Console.WriteLine("Calories Burned: " & Item(2))
  217. Loop
  218. Console.ReadLine()
  219. End Sub
  220. Sub Edit_Personal_Details()
  221. Console.Clear()
  222. End Sub
  223. Sub Add_Personal_Details()
  224. Console.Clear()
  225. Dim FullLine As String = ""
  226. Dim first As String = ""
  227. Dim last As String = ""
  228. Dim age As String = ""
  229. Dim postcode As String = ""
  230. Dim city As String = ""
  231. Dim house_number As String = ""
  232. Dim total_cal As String = ""
  233. Console.WriteLine("Please input Your firstname.")
  234. first = Console.ReadLine()
  235. Console.WriteLine("Please input Your lastname")
  236. last = Console.ReadLine()
  237. Console.WriteLine("Please input Your age")
  238. age = Console.ReadLine()
  239. Console.WriteLine("Please input You postcode")
  240. postcode = Console.ReadLine()
  241. Console.WriteLine("Please input the city you live in.")
  242. city = Console.ReadLine()
  243. Console.WriteLine("Please input Your house number.")
  244. house_number = Console.ReadLine()
  245. Console.WriteLine("Are you sure you want to save this input?")
  246. Console.WriteLine("1 -Yes")
  247. Console.WriteLine("2 -No, Return to menu")
  248. confirm = Console.ReadLine()
  249. Select Case confirm
  250. Case "1"
  251. FileOpen(1, personal_details_path, OpenMode.Append)
  252. FullLine = user & "," & first & "," & last & "," & age & "," & postcode & "," & city & "," & house_number & "," & total_cal
  253. PrintLine(1, FullLine)
  254. FileClose(1)
  255.  
  256. Console.ForegroundColor = ConsoleColor.Red
  257. Console.WriteLine("Personal Details Saved!")
  258. Console.WriteLine("Any key will return to menu.")
  259. Console.ForegroundColor = ConsoleColor.White
  260. Console.ReadKey()
  261. athlete_menu()
  262. Case "2"
  263. athlete_menu()
  264. End Select
  265.  
  266. End Sub
  267. Sub Delete_user()
  268.  
  269. End Sub
  270. Sub add_user()
  271. Console.Clear()
  272. Dim FullLine As String = ""
  273. Dim username As String = ""
  274. Dim password As String = ""
  275. Dim type As String = "ATHLETE"
  276. Dim name As String = ""
  277. Console.WriteLine("Please input the Username.")
  278. username = Console.ReadLine()
  279. Console.WriteLine("Please input the Password.")
  280. password = Console.ReadLine()
  281. Console.WriteLine("Please input the Name of Athlete.")
  282. name = Console.ReadLine()
  283. Console.WriteLine("Are you sure you want to add this user?")
  284. Console.WriteLine("1 -Yes")
  285. Console.WriteLine("2 -No, Return to menu")
  286. confirm = Console.ReadLine()
  287. Select Case confirm
  288. Case "1"
  289. FileOpen(1, login_path, OpenMode.Append)
  290. FullLine = username & "," & password & "," & type & "," & name
  291. PrintLine(1, FullLine)
  292. FileClose(1)
  293. Console.ForegroundColor = ConsoleColor.Red
  294. Console.WriteLine("New User Added")
  295. Console.WriteLine("Any key will return to menu.")
  296. Console.ForegroundColor = ConsoleColor.White
  297. Console.ReadKey()
  298. admin_menu()
  299. Case "2"
  300. admin_menu()
  301. End Select
  302. End Sub
  303. Sub save()
  304. Console.Clear()
  305. Console.WriteLine("You have burned " & calburned & " calories.")
  306. Console.WriteLine("Do you want go save this record?")
  307. Console.WriteLine("1 -Yes")
  308. Console.WriteLine("2 -No, will go back to manu")
  309. Dim save As Char = Console.ReadLine
  310. Select Case save
  311. Case "1"
  312. Dim FullLine As String = ""
  313. FileOpen(1, training_record_path, OpenMode.Append)
  314. FullLine = user & "," & training_type & "," & calburned
  315. PrintLine(1, FullLine)
  316. FileClose(1)
  317. Console.ForegroundColor = ConsoleColor.Red
  318. Console.WriteLine("Training Saved!")
  319. Console.WriteLine("Press Any Key To Return To Menu")
  320. Console.ForegroundColor = ConsoleColor.White
  321. Console.ReadKey()
  322. athlete_menu()
  323. Case "2"
  324. athlete_menu()
  325. End Select
  326. End Sub
  327. Sub bullble_sort()
  328.  
  329. End Sub
  330. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement