Advertisement
Guest User

rc

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