Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.19 KB | None | 0 0
  1. import random
  2. all_students = []
  3. username = "kman"
  4. password = "kman1"
  5. class Student:
  6.     idCounter = 1
  7.     def __init__(self, firstname, lastname, gender, address):
  8.         self.id = Student.idCounter
  9.         Student.idCounter += 1
  10.         self.group = ""
  11.         self.email = ""
  12.         self.gender = gender
  13.         self.surname = lastname
  14.         self.forename = firstname
  15.         self.dob = ""
  16.         self.address = address
  17.         self.phone = ""
  18.         self.GenerateData()
  19.         all_students.append(self)
  20.        
  21.     def GenerateData(self):
  22.         phone = ""
  23.         while len(phone) < 8:
  24.             x = random.randint(0,9)
  25.             phone += (str(x))
  26.             if len(phone) == 3:
  27.                 phone += "-"
  28.         self.phone = phone
  29.        
  30.         self.email = self.forename[0] + self.surname + "@CoolSchool.com"
  31.        
  32.         self.dob = str(random.randint(1,12)) + "/" + str(random.randint(1,30)) + "/" + str(random.randint(1990, 2000))
  33.        
  34.        
  35. #Create all students
  36. s = Student("Mike", "Powers", "M", "20 Boombam st")
  37. s = Student("Michelle", "Malcovich", "F", "511 Main st")
  38. s = Student("Tyrone", "Diaz", "M", "745 Court ave")
  39. s = Student("Shelby", "Goodell", "F", "234 Sidler ave")
  40. s = Student("Tim", "Smith", "M", "12 Tryna st")
  41. s = Student("Alyssa", "Hall", "F", "235 Groofus st")
  42. s = Student("John", "Rogers", "M", "34 Bimban ave")
  43. s = Student("Hallee", "Griffan", "F", "27 Poodle st")
  44. s = Student("Jared", "Renza", "M", "84 Grazkot st")
  45. s = Student("Nicole", "Deluc", "F", "655 Shoodle ave")
  46. s = Student("Isaiah", "Johnson", "M", "890 Whazop st")
  47. s = Student("Sam", "Coolio", "F", "221 Nootloot st")
  48. s = Student("Johnny", "John", "M", "234 Leedle ave")
  49. s = Student("Jordan", "Moon", "F", "532 Shakim st")
  50. s = Student("Michael", "Richter", "M", "79 Krepey st")
  51. s = Student("Samantha", "Powell", "F", "16 Kiminle st")
  52. s = Student("Joe", "RoRogo", "M", "22 Alchop st")
  53. s = Student("Tina", "Gillby", "F", "346 Quilor ave")
  54. s = Student("Jonah", "Hill", "M", "197 Garfam st")
  55. s = Student("Kim", "Kardashian", "F", "51 Sneed st")
  56. s = Student("Nick", "Collabela", "M", "65 Offside ave")
  57. s = Student("Nicky", "Nash", "F", "237 Alchop st")
  58. s = Student("Chad", "AlphaBro", "M", "46 Boombam st")
  59. s = Student("Stacy", "Normie", "F", "123 Krepey ave")
  60. s = Student("Marjorie", "Simpson", "F", "131 Coolup st")
  61.  
  62.  
  63.  
  64. running = True
  65. state = "Logging"
  66. while running:
  67.     if state == "Logging":
  68.         print "Type your username: "
  69.         user = raw_input("")
  70.         if user == username:
  71.             print "Type your password: "
  72.             passw = raw_input("")
  73.             if passw == password:
  74.                 state = "Main"
  75.     if state == "Main":
  76.         print "1)Enter student details."
  77.         print "2)View student info."
  78.         print "3)Reports."
  79.         print "4)Logout."
  80.         print "Input the corresponding number. "
  81.         ans = str(raw_input(""))
  82.         if ans == "1":
  83.             state = "Entering"
  84.         elif ans == "2":
  85.             state = "Viewing"
  86.         elif ans == "3":
  87.             state = "Reports"
  88.         elif ans == "4":
  89.             running = False
  90.         elif ans == "exit":
  91.             running = False
  92.         else:
  93.             print "Didn't recognize command. Try again."
  94.  
  95.        
  96.     if state == "Entering":
  97.         chosen = None
  98.         print ""
  99.         print "Type exit to return"
  100.         id = raw_input("Enter students ID. (1-25)")
  101.         if id.lower() == "exit":
  102.             print ""
  103.             state = "Main"
  104.         else:    
  105.            
  106.             if int(id) >= 1 and int(id) <= 25:
  107.                 for s in all_students:
  108.                     if str(s.id) == str(id):
  109.                         chosen = s
  110.             else:
  111.                 print "ID not found."
  112.                
  113.             if chosen:
  114.                 print ""
  115.                 print "Name: {} {}".format(chosen.forename, chosen.surname)
  116.                 print "Gender, Dob: {} {}".format(chosen.gender, chosen.dob)
  117.                 print "1)Phone: {}".format(chosen.phone)
  118.                 print "2)Email: {}".format(chosen.email)
  119.                 print "3)Address: {}".format(chosen.address)
  120.                 print "4)Group: {}".format(chosen.group)
  121.                 print ""
  122.                 print "Type the number, then the value."
  123.                 print "Example: 2 StudentEmail@gmail.com"
  124.                 ans = raw_input("")
  125.                 alist = ans.split(' ')
  126.                 command = str(alist[0])
  127.                
  128.                 if command == "exit":
  129.                     print ""
  130.                     state = "Main"
  131.                 else:
  132.                     if len(alist) > 1:
  133.                         value = alist[1]
  134.                         if int(command) >= 1 and int(command) <= 4:
  135.                             if command == "1":
  136.                                 chosen.phone = str(value)
  137.                             elif command == "2":
  138.                                 chosen.email = value
  139.                             elif command == "3":
  140.                                 chosen.address = value
  141.                             elif command == "4":
  142.                                 chosen.group = value
  143.                         else:
  144.                             print "Invalid Input. "
  145.                     else:
  146.                         print "Invalid Input. "
  147.                        
  148.                    
  149.     if state == "Viewing":
  150.         chosen = None
  151.         print ""
  152.         print "Type exit to return"
  153.         id = raw_input("Enter students ID. (1-25)")
  154.        
  155.         if id.lower() == "exit":
  156.             print ""
  157.             state = "Main"
  158.         else:    
  159.            
  160.             if int(id) >= 1 and int(id) <= 25:
  161.                 for s in all_students:
  162.                     if str(s.id) == str(id):
  163.                         chosen = s
  164.             else:
  165.                 print "ID not found."
  166.                
  167.             if chosen:
  168.                 print ""
  169.                 print "Name: {} {}".format(chosen.forename, chosen.surname)
  170.                 print "Gender, Dob: {} {}".format(chosen.gender, chosen.dob)
  171.                 print "1)Phone: {}".format(chosen.phone)
  172.                 print "2)Email: {}".format(chosen.email)
  173.                 print "3)Address: {}".format(chosen.address)
  174.                 print "4)Group: {}".format(chosen.group)
  175.                 print "Type the number, then the value."
  176.                 print "Example: 2 StudentEmail@gmail.com"
  177.        
  178.     if state == "Reports":
  179.         print "--No reports currently available--"
  180.         print ""
  181.         state = "Main"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement