Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Successful Keyword Searching Initiating Research On Popular Topics Using Electronic Databases

Authors: Randall MacDonald, Susan MacDonald

1st Edition

0313306761, 978-0313306761

More Books

Students also viewed these Databases questions