Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- all_students = []
- username = "kman"
- password = "kman1"
- class Student:
- idCounter = 1
- def __init__(self, firstname, lastname, gender, address):
- self.id = Student.idCounter
- Student.idCounter += 1
- self.group = ""
- self.email = ""
- self.gender = gender
- self.surname = lastname
- self.forename = firstname
- self.dob = ""
- self.address = address
- self.phone = ""
- self.GenerateData()
- all_students.append(self)
- def GenerateData(self):
- phone = ""
- while len(phone) < 8:
- x = random.randint(0,9)
- phone += (str(x))
- if len(phone) == 3:
- phone += "-"
- self.phone = phone
- self.email = self.forename[0] + self.surname + "@CoolSchool.com"
- self.dob = str(random.randint(1,12)) + "/" + str(random.randint(1,30)) + "/" + str(random.randint(1990, 2000))
- #Create all students
- s = Student("Mike", "Powers", "M", "20 Boombam st")
- s = Student("Michelle", "Malcovich", "F", "511 Main st")
- s = Student("Tyrone", "Diaz", "M", "745 Court ave")
- s = Student("Shelby", "Goodell", "F", "234 Sidler ave")
- s = Student("Tim", "Smith", "M", "12 Tryna st")
- s = Student("Alyssa", "Hall", "F", "235 Groofus st")
- s = Student("John", "Rogers", "M", "34 Bimban ave")
- s = Student("Hallee", "Griffan", "F", "27 Poodle st")
- s = Student("Jared", "Renza", "M", "84 Grazkot st")
- s = Student("Nicole", "Deluc", "F", "655 Shoodle ave")
- s = Student("Isaiah", "Johnson", "M", "890 Whazop st")
- s = Student("Sam", "Coolio", "F", "221 Nootloot st")
- s = Student("Johnny", "John", "M", "234 Leedle ave")
- s = Student("Jordan", "Moon", "F", "532 Shakim st")
- s = Student("Michael", "Richter", "M", "79 Krepey st")
- s = Student("Samantha", "Powell", "F", "16 Kiminle st")
- s = Student("Joe", "RoRogo", "M", "22 Alchop st")
- s = Student("Tina", "Gillby", "F", "346 Quilor ave")
- s = Student("Jonah", "Hill", "M", "197 Garfam st")
- s = Student("Kim", "Kardashian", "F", "51 Sneed st")
- s = Student("Nick", "Collabela", "M", "65 Offside ave")
- s = Student("Nicky", "Nash", "F", "237 Alchop st")
- s = Student("Chad", "AlphaBro", "M", "46 Boombam st")
- s = Student("Stacy", "Normie", "F", "123 Krepey ave")
- s = Student("Marjorie", "Simpson", "F", "131 Coolup st")
- running = True
- state = "Logging"
- while running:
- if state == "Logging":
- print "Type your username: "
- user = raw_input("")
- if user == username:
- print "Type your password: "
- passw = raw_input("")
- if passw == password:
- state = "Main"
- if state == "Main":
- print "1)Enter student details."
- print "2)View student info."
- print "3)Reports."
- print "4)Logout."
- print "Input the corresponding number. "
- ans = str(raw_input(""))
- if ans == "1":
- state = "Entering"
- elif ans == "2":
- state = "Viewing"
- elif ans == "3":
- state = "Reports"
- elif ans == "4":
- running = False
- elif ans == "exit":
- running = False
- else:
- print "Didn't recognize command. Try again."
- if state == "Entering":
- chosen = None
- print ""
- print "Type exit to return"
- id = raw_input("Enter students ID. (1-25)")
- if id.lower() == "exit":
- print ""
- state = "Main"
- else:
- if int(id) >= 1 and int(id) <= 25:
- for s in all_students:
- if str(s.id) == str(id):
- chosen = s
- else:
- print "ID not found."
- if chosen:
- print ""
- print "Name: {} {}".format(chosen.forename, chosen.surname)
- print "Gender, Dob: {} {}".format(chosen.gender, chosen.dob)
- print "1)Phone: {}".format(chosen.phone)
- print "2)Email: {}".format(chosen.email)
- print "3)Address: {}".format(chosen.address)
- print "4)Group: {}".format(chosen.group)
- print ""
- print "Type the number, then the value."
- print "Example: 2 StudentEmail@gmail.com"
- ans = raw_input("")
- alist = ans.split(' ')
- command = str(alist[0])
- if command == "exit":
- print ""
- state = "Main"
- else:
- if len(alist) > 1:
- value = alist[1]
- if int(command) >= 1 and int(command) <= 4:
- if command == "1":
- chosen.phone = str(value)
- elif command == "2":
- chosen.email = value
- elif command == "3":
- chosen.address = value
- elif command == "4":
- chosen.group = value
- else:
- print "Invalid Input. "
- else:
- print "Invalid Input. "
- if state == "Viewing":
- chosen = None
- print ""
- print "Type exit to return"
- id = raw_input("Enter students ID. (1-25)")
- if id.lower() == "exit":
- print ""
- state = "Main"
- else:
- if int(id) >= 1 and int(id) <= 25:
- for s in all_students:
- if str(s.id) == str(id):
- chosen = s
- else:
- print "ID not found."
- if chosen:
- print ""
- print "Name: {} {}".format(chosen.forename, chosen.surname)
- print "Gender, Dob: {} {}".format(chosen.gender, chosen.dob)
- print "1)Phone: {}".format(chosen.phone)
- print "2)Email: {}".format(chosen.email)
- print "3)Address: {}".format(chosen.address)
- print "4)Group: {}".format(chosen.group)
- print "Type the number, then the value."
- print "Example: 2 StudentEmail@gmail.com"
- if state == "Reports":
- print "--No reports currently available--"
- print ""
- state = "Main"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement