Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 1 Modify the array-based UnsortedType (which uses ItemType class) based upon the following instructions: Modify the UnsortedType class to use a dynamically allocated array

Problem 1

Modify the array-based UnsortedType (which uses ItemType class) based upon the following instructions:

Modify the UnsortedType class to use a dynamically allocated array to store the items (this will replace the fixed size array info).

Modify zero-parameter constructor so that it allocates an array of size 10 (default size)

Modify the parameterized constructor that takes an int as parameter, specifying the size of array to allocate.

Add a destructor for the class (why do you need to do so?). Write your answer as a comment above the destructor.

Modify IsFull( ): It will return true, if the current length of list equals to the size of array; otherwise, it returns false.

Overload index operator (i.e., []) to return the reference of i-th element in the list.

Modify PutItem( ) so that it can be called to put an item into a "full" list:

1. Allocate a larger array (which can be double of current size)

2. Copy current array elements to the new array

3. Delete current array

4. insert item into new array

5. set info points to new array

Problem 2

Write a class named Appointment to represent a linked list of appointments. A node will represent an appointment, which consists of Year, Month, and Day. In this scenario, a node will have multiple info fields in addition to a pointer (Next).

Implement the following member functions:

1. Constructor

2. Destructor

3. PutItem: add a new appointment to the list

4. DeleteItem: delete an existing appointment

5. IsFull()

6. CompareAppoint: compare two appointments

7. SearchItem: find whether an appointment exists in the list of appointments or not

8. EmptyList: empty the list of appointments

9. PrintList: display the list of existing appointments

Problem 3

Write main function that runs in a loop that allow the user to choose a command:

1. Display: display all appointments

2. Add: add a new appointment. If there is already an appointment on the date, reports error.

3. Search: search for an appointment on a user specified date

4. Delete: delete an appointment on a user specified date

5. Quit: to quite the program

When a command is chosen, the program shall prompt the user to enter relevant info, for example, to add a new appointment, the program prompts the user to enter the date and then create an Appointment object, call PutItem() to add the item into the list.

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

g) works of art exhibited in public or private

Answered: 1 week ago