This assignment will help you get practice with: Abstract Data Types Inheritance…
- User
This assignment will help you get practice with:
codeAbstract Data Types Inheritance Polymorphism C++ pointers C++ Classes C++ virtual and pure virtual functions C++ Class Templates C++ ArraysTask: A container class is a data type that is capable of holding a collection of items and provides functions to access them. Bag is an example of a container class. It is an unordered collection of items that may have duplicates. In this assignment, you are asked to design and develop an abstract Bag class, called BagInterface, with the following fixed collection of operations:
codeInsert an item of any type into a bag Query the bag contents: two queries Is an item in the bag? How many copies of an item is in the bag? Remove an item from the bag clear the bag Get the size of the bag How many items are there in the bag? Check if the bag is empty Check if the bag is full Assume the bag capacity is 20In addition to BagInterface, you are asked to implement two classes of bag implementations: PlainBag and MagicChangeBag.
PlainBag is a simple container that holds items of any type using an array implementation.
MagicChangeBag is also very similar to PlainBag, with two exceptions. When an item is inserted into a magic change bag, it’ll magically disappear, and bag looks empty. Whenever a remove operation is invoked, all the items, except the one is removed will appear.
You are given the following [AssignmentBag.cpp]
Download AssignmentBag.cpp] (contains the main function) diver application together with a sample run.
To do:
codeCreate BagInterface abstract class Implement PlainBag and MagicChangeBag classes Use templates Use virtual and pure virtual functions Use arrays Provide UML class diagram for your solutionImportant Notes:
codeYou are not allowed to modify main.cpp implementation. Please use it as it is. Before you submit your work, please make sure the entire folder works. You are not required to handle the edge cases in this assignment. BagInterface.h PlainBag.h and PlaingBag.cpp MagicChangeBag.h and MagicChangeBag.cpp - Assistant
- User
you also need a print()
- Assistant
Apologies for the oversight. Here's an updated version of the PlainBag class with the addition of the print() function:
cpp - User
but i want to the array when i remove the item just like this Testing Magic Change Bag Bag content: Number of items:0 Number of ones:0 Bag content:4 2 4 6 5 4 4 1 3 2 2 3 3 2 3 4 2 2 4 4 Bag content:4 2 4 6 5 4 4 3 2 2 3 3 2 3 4 2 2 4 4 Number of items:19 Number of ones:0 Number of twos:6
- Assistant
Apologies for the confusion. Here's the updated version of the MagicChangeBag class with the modified remove() function:
cpp - User
for magic change bag, i want when insert() is evoked, the array is empty but not empty. and when i use remove(), the array will show up except for the removed one
- Assistant
Apologies for the confusion. Here's an updated version of the MagicChangeBag class with the modified insert() and remove() functions:
cpp