Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
eventPlanningSystem
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sully.khalifa
eventPlanningSystem
Commits
6b569c97
Commit
6b569c97
authored
Jan 19, 2023
by
sully.khalifa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
last commit to branch
parent
36fe268e
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
236 additions
and
157 deletions
+236
-157
event_planning_system.py
event_planning_system.py
+0
-157
event_planning_system__final.py
event_planning_system__final.py
+236
-0
No files found.
event_planning_system.py
deleted
100644 → 0
View file @
36fe268e
'''The Event class has a name, organizer, and description,
and it also has a list of invitees and a menu. The class has
methods to add invitees and view the list of invitees.'''
class
Event
:
def
__init__
(
self
,
name
,
organizer
,
description
):
self
.
name
=
name
self
.
organizer
=
organizer
self
.
description
=
description
self
.
invitees
=
[]
self
.
menu
=
Menu
()
def
add_invitee
(
self
,
invitee
):
self
.
invitees
.
append
(
invitee
)
def
view_invitees
(
self
):
for
invitee
in
self
.
invitees
:
print
(
invitee
)
'''The Invitee class has a name, RSVP status, whether or not
they are bringing a plus one, and any dietary requirements.
The class has a __str__ method that formats the
invitee's information into a human-readable string.'''
class
Invitee
:
def
__init__
(
self
,
name
,
rsvp
=
False
,
plus_one
=
False
,
dietary_req
=
None
):
self
.
name
=
name
self
.
rsvp
=
rsvp
self
.
plus_one
=
plus_one
self
.
dietary_req
=
dietary_req
def
__str__
(
self
):
return
f
"Name: {self.name}, RSVP: {'Yes' if self.rsvp else 'No'}, Plus One: {'Yes' if self.plus_one else 'No'}, Dietary Requirements: {self.dietary_req}"
'''The Menu class has a dictionary of items, where each
item is a meal and the value is a list of invitees.
The class has methods to add items and view the menu.'''
class
Menu
:
def
__init__
(
self
):
self
.
items
=
{}
def
add_item
(
self
,
meal
,
invitees
):
self
.
items
[
meal
]
=
invitees
def
view_menu
(
self
):
for
meal
,
invitees
in
self
.
items
.
items
():
print
(
f
"{meal}: {', '.join(invitees)}"
)
'''The EventFactory class has methods to create events and invitees.'''
class
EventFactory
:
def
create_event
(
self
,
name
,
organizer
,
description
):
return
Event
(
name
,
organizer
,
description
)
def
create_invitee
(
self
,
name
,
rsvp
=
False
,
plus_one
=
False
,
dietary_req
=
None
):
return
Invitee
(
name
,
rsvp
,
plus_one
,
dietary_req
)
'''The EventView class has methods to create events,
add invitees, view the list of invitees, add menu items,
and view the menu. The class uses an EventFactory
object to create events and invitees.'''
class
EventView
:
def
__init__
(
self
,
event_factory
):
self
.
event_factory
=
event_factory
self
.
events
=
[]
def
create_event
(
self
):
name
=
input
(
"Enter event name: "
)
organizer
=
input
(
"Enter organizer name: "
)
description
=
input
(
"Enter event description: "
)
event
=
self
.
event_factory
.
create_event
(
name
,
organizer
,
description
)
self
.
events
.
append
(
event
)
print
(
f
"Event {name} created successfully!"
)
def
add_invitee
(
self
):
event_name
=
input
(
"Enter event name: "
)
event
=
next
((
x
for
x
in
self
.
events
if
x
.
name
==
event_name
),
None
)
if
event
:
name
=
input
(
"Enter invitee name: "
)
rsvp
=
input
(
"Has invitee RSVPd? (y/n)"
)
.
lower
()
==
"y"
plus_one
=
input
(
"Is invitee bringing a plus one? (y/n)"
)
.
lower
()
==
"y"
dietary_req
=
input
(
"Enter invitee dietary requirements: "
)
invitee
=
self
.
event_factory
.
create_invitee
(
name
,
rsvp
,
plus_one
,
dietary_req
)
event
.
add_invitee
(
invitee
)
print
(
f
"Invitee {name} added to event {event_name}"
)
else
:
print
(
f
"Event {event_name} not found."
)
def
view_invitees
(
self
):
event_name
=
input
(
"Enter event name: "
)
event
=
next
((
x
for
x
in
self
.
events
if
x
.
name
==
event_name
),
None
)
if
event
:
event
.
view_invitees
()
else
:
print
(
f
"Event {event_name} not found."
)
def
add_menu_item
(
self
):
event_name
=
input
(
"Enter event name: "
)
event
=
next
((
x
for
x
in
self
.
events
if
x
.
name
==
event_name
),
None
)
if
event
:
meal
=
input
(
"Enter meal name: "
)
invitees
=
input
(
"Enter invitees (comma separated): "
)
.
split
(
","
)
event
.
menu
.
add_item
(
meal
,
invitees
)
print
(
f
"Meal {meal} added to event {event_name}"
)
else
:
print
(
f
"Event {event_name} not found."
)
def
view_menu
(
self
):
event_name
=
input
(
"Enter event name: "
)
event
=
next
((
x
for
x
in
self
.
events
if
x
.
name
==
event_name
),
None
)
if
event
:
event
.
menu
.
view_menu
()
else
:
print
(
f
"Event {event_name} not found."
)
def
search_invitee
(
self
):
invitee_name
=
input
(
"Enter invitee name: "
)
for
event
in
self
.
events
:
invitee
=
next
((
x
for
x
in
event
.
invitees
if
x
.
name
==
invitee_name
),
None
)
if
invitee
:
print
(
f
"Invitee {invitee_name} found in event {event.name}"
)
print
(
f
"RSVP: {invitee.rsvp}"
)
print
(
f
"Plus One: {invitee.plus_one}"
)
print
(
f
"Dietary Requirements: {invitee.dietary_req}"
)
return
print
(
f
"Invitee {invitee_name} not found."
)
def
main
():
event_factory
=
EventFactory
()
event_view
=
EventView
(
event_factory
)
while
True
:
print
(
"1. Create Event"
)
print
(
"2. Add Invitee"
)
print
(
"3. View Invitees"
)
print
(
"4. Add Menu Item"
)
print
(
"5. View Menu"
)
print
(
"6. Search Invitee"
)
print
(
"7. Exit"
)
choice
=
input
(
"Enter your choice: "
)
if
choice
==
"1"
:
event_view
.
create_event
()
elif
choice
==
"2"
:
event_view
.
add_invitee
()
elif
choice
==
"3"
:
event_view
.
view_invitees
()
elif
choice
==
"4"
:
event_view
.
add_menu_item
()
elif
choice
==
"5"
:
event_view
.
view_menu
()
elif
choice
==
"6"
:
event_view
.
search_invitee
()
elif
choice
==
"7"
:
break
if
__name__
==
"__main__"
:
main
()
event_planning_system__final.py
0 → 100644
View file @
6b569c97
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment