Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

- Do all exercises (full solution) - Practice dynamic memory allocation and deep, shallow copies. - Write code using basic C++ syntax and functions. Ex

- Do all exercises (full solution)
- Practice dynamic memory allocation and deep, shallow copies.
- Write code using basic C++ syntax and functions.
image text in transcribed
image text in transcribed
Ex 1. Customer Class Define and implement a class Customer as described below: Note: the customer class is already implemented. Ex 2. Restaurant Class Data members: - restaurant name as string. - restaurant location as string. - num_ of_customers as integer: number of customers currently in the customers. - capacity as integer. maximum number of customers the customers can accommodate. - customers: Customer array, its size is the capacity. Function member: - A parameterized constructor that receives: Restaurant number, location and capacity, you have to use this pointer. - Copy constructor. The copy must be a deep copy. - Destructer. - void set_customers (Customer * n, int Num_of_customers) which sets the Customers for the Restaurant according to the received array of customers. Note that this function can be used to change the Customers as well. - Void add (Customer C), that adds a customer to the Customers if the number of customers is less than the capacity. - Void delete_first 0 , that deletes the first customer from the Customers. - Void remove_customer (string name), searches for the given customer's name and removes it from the Customers. If the customer is not in the Customers, the function does nothing - Void expand 0 , that expands the capacity of the Customers by 5 : To expand: 1- Dynamically allocate a new array whose capacity is the capacity plus five. 2 - Copy the customers from the first list to the new array. 3. Deallocate the old list and make its pointer point at the new list. 4. Update the capacity of the Customers to new capacity (capacity +5). - Void print_details 0 , that prints all details of a Restaurant including customers details. Ex 3. Driver - Create a Restaurant object for customers of a capacity of 10 . - Create an array of type Customer with size 5. Ask the user to enter the information of the customers. - Add these customers to the restaurant. - Create a new customer, then add him to the restaurant. - Remove the customer whose name is equivalent to your name from the customers array. - Print all information of the restaurant object

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

More Books

Students also viewed these Databases questions

Question

(2) The function f (x) = sin(x) is a probability density function.

Answered: 1 week ago

Question

1. Define and explain culture and its impact on your communication

Answered: 1 week ago