Answered step by step
Verified Expert Solution
Question
1 Approved Answer
0 2 - Graded Participation Your participation score for this module is based on posting an answer to the practice question below to this discussion
Graded Participation
Your participation score for this module is based on posting an answer to the practice question below to this discussion board. Review the
information on the Graded Participation Information for more details and the Discussion Board Tips for details on using Canvas discussion boards.
Make sure to read the posting code to Canvas guide to make your answer look nice on the discussion board!
Resist the temptation to just type in an answer. Make sure to try out your answer on hills! You can expect to spend an hour or more coming up with
an answer to the practice question. Note: this week there is only one practice question, in most other weeks, there will be or
Question
Implement the generic Box class discussed in the videospdfs Copying and pasting from the slide is fine.
Implement the findBox function discussed in the videospdfs Instead of an array of Boxes containing strings, ie BoxFor this assignment, I've started an arraybased list implementation to track songs in a playlist. Download the
code TrackSongs.cpp given in the module and familiarize yourself with it Don't forget that list ADT's start at
position but the underlying array used in this class starts at position like any array.
Once you're comfortable with the code, you have four tasks:
Replace item at position pos in the list with the new parameter item. Throw the invalidargument exception if
pos or pos getLength
Remove the item at position pos. You need to update the state of the list, that is shift items after pos over one
to get rid of the gap left by the removed item and update numltems. If the remove operation is successful,
return true. If it was not successful, for example because pos is out of range, return false.
bool insertint pos, const ItemType& item
Also, improve the insert function. Currently, if you try to add an item to a full list, insert returns false and does
not add the item. Improve this so that it dynamically allocates more memory to the list to make room for the
new item using the new operator. You can add another CHUNKSIZE amount of memory, or any other amount
of memory you think makes sense. Don't forget to deallocate any existing memory, eg using delete
int main
Now demonstrate that your functions work in main by removing songs from the list and changing songs in the
list. You may make modifications to the user interface to let the user do this on the fly, or just hard code a few
removalschanges in main Make sure to demonstrate your exception handling for setEntry For the improved
insert function, make sure you demonstrate that the new functionality works, eg by changing CHUNKSIZE to
a low number like and inserting more than songs into the list.
Submission
Submit your updated C file with the new functions, the modified insert function, the modified main
function, and sufficient sample output demonstrating all the new functionality in one plain text cpp file.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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