Answered step by step
Verified Expert Solution
Question
00
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 indicates the party is incomplete and so cannot yet be seated and party complete being indicates the party is complete, and therefore can be seated when a table becomes available. The code below implents this as a class. The asdict method can be used to return a dictionary of the bookings which can be used for testing purposes. run i marray class Bookings: A dynamic array implementation to store bookings. def initself: Create a new empty array. self.bookings DynamicArray def addbookingself reservationID: int, name: str table: int None: Adds a booking to the array. size self.bookings.length self.bookings.resizesize self.bookings.setitemsizereservationID name, table, def getpartycompleteself reservationID: int int: Precondition: reservationID exists. for index in rangeselfbookings.length: booking self.bookings.getitemindex if booking reservationID: return booking def asdictself None: Returns dictionary version of the bookings array. bookings dict for index in rangeselfbookings.length: booking self.bookings.getitemindex bookingsbooking bookingbookingbooking 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:
The software is being further developed to store whether the whole party is present or not; party complete being indicates the party is incomplete and so cannot yet be seated and party complete being indicates the party is complete, and therefore can be seated when a table becomes available.
The code below implents this as a class. The asdict method can be used to return a dictionary of the bookings which can be used for testing purposes.
run i marray
class Bookings:
A dynamic array implementation
to store bookings.
def initself:
Create a new empty array.
self.bookings DynamicArray
def addbookingself reservationID: int, name: str table: int None:
Adds a booking to the array.
size self.bookings.length
self.bookings.resizesize
self.bookings.setitemsizereservationID name, table,
def getpartycompleteself reservationID: int int:
Precondition: reservationID exists.
for index in rangeselfbookings.length:
booking self.bookings.getitemindex
if booking reservationID:
return booking
def asdictself None:
Returns dictionary version
of the bookings array.
bookings dict
for index in rangeselfbookings.length:
booking self.bookings.getitemindex
bookingsbooking bookingbookingbooking
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
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started