Question: The software is being further developed to store whether the whole party is present or not; party complete being 0 indicates the party is incomplete

The software is being further developed to store whether the whole party is present or not; party complete being 0 indicates the party is incomplete (and so cannot yet be seated), and party complete being 1 indicates the party is complete, and therefore can be seated when a table becomes available.
The code below implents this as a class. The as_dict method can be used to return a dictionary of the bookings which can be used for testing purposes.
%run -i m269_array
class Bookings:
"""A dynamic array implementation
to store bookings.
"""
def __init__(self):
"""Create a new empty array.
"""
self.bookings = DynamicArray(0)
def add_booking(self, reservation_ID: int, name: str, table: int)-> None:
"""Adds a booking to the array.
"""
size = self.bookings.length()
self.bookings.resize(size+1)
self.bookings.set_item(size,(reservation_ID, name, table, 0))
def get_party_complete(self, reservation_ID: int)-> int:
"""Precondition: reservation_ID exists.
"""
for index in range(self.bookings.length()):
booking = self.bookings.get_item(index)
if booking[0]== reservation_ID:
return booking[3]
def as_dict(self)-> None:
"""Returns dictionary version
of the bookings array.
"""
bookings = dict()
for index in range(self.bookings.length()):
booking = self.bookings.get_item(index)
bookings[booking[0]]= booking[1],booking[2],booking[3]
return bookings
Write a problem definition for a function which returns a tuple with two values: the first being the count of bookings with parties which are incomplete and the second being the count of bookings with parties which are complete.
Write your answer here
Function:
Inputs:
Preconditions:
Output:
Postconditions:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!