SHARE
TWEET

Untitled

a guest Oct 2nd, 2017 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Please enter name for event 1: bob
  2. Please enter date for event 1: 11/24/91
  3. Please enter number of attendees for event 166
  4. ---------------
  5. Please enter name for event 2: joe
  6. Please enter date for event 2: 11/01/17
  7. Please enter number of attendees for event 299
  8. ---------------
  9. Please enter name for event 3: tim
  10. Please enter date for event 3: 030116
  11. Please enter number of attendees for event 3100
  12. ---------------
  13. Please enter name for event 4: lucy
  14. Please enter date for event 4: 040688
  15. Please enter number of attendees for event 42
  16. ---------------
  17. Please enter name for event 5: timmy
  18. Please enter date for event 5: 090816
  19. Please enter number of attendees for event 54
  20. ---------------
  21. ----- Events-----
  22. <__main__.Socialevent object at 0x00000188172426A0>
  23. Traceback (most recent call last):
  24.   File "C:\Users\kills\Desktop\attendees.py", line 50, in <module>
  25.     main()
  26.   File "C:\Users\kills\Desktop\attendees.py", line 47, in main
  27.     events.remove(target)
  28. ValueError: list.remove(x): x not in list
  29.  
  30. #Assignment 2 Part 2 Social event
  31. class Socialevent:
  32.     #private fields within class
  33.     def __init__(self, eventtitle, date, attendees):
  34.         self.eventtitle = eventtitle
  35.         self.date = date
  36.         self.attendees = attendees
  37.     #@eventtitle.getter
  38.     def getEventtitle(self):
  39.         return self.eventtitle
  40.     #@date.getter
  41.     def getDate(self):
  42.         return self.date
  43.     #@attendees.getter
  44.     def getAttendees(self):
  45.         return self.attendees
  46.     #@eventtitle.setter
  47.     def setEventtitle(self, eventtitle):
  48.         self.eventtitle = eventtitle
  49.     #@date.setter
  50.     def setDate(self, date):
  51.         self.date = date
  52.     #@attendees.setter
  53.     def setAttendees(self, attendees):
  54.         self.attendees = attendees
  55. #get event class
  56. def get_event(n):
  57.     title = input("Please enter name for event {0}: ".format(n))
  58.     date = input("Please enter date for event {0}: ".format(n))
  59.     attendees = int(input("Please enter number of attendees for event {0}".format(n)))
  60.     print("-" * 15)
  61.     return Socialevent(title, date, attendees)
  62. #main method
  63. def main():
  64.     #put events as a list and loop five times
  65.     events = []
  66.     for i in range(5):
  67.         events.append(get_event(i+1))
  68.     #sort and get event based on number of attendees
  69.     print("-" * 5 + " Events" + "-" * 5)
  70.     while len(events) > 0:
  71.         target = 0
  72.         for i in range(len(events)):
  73.             if events[i].getAttendees() > events[target].getAttendees():
  74.                 target = i
  75.         print(events[target])
  76.         events.remove(target)
  77.  
  78. if __name__ == "__main__":
  79.     main()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top