Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

People use bags all the time for a variety of different purposes. Bags are containers that hold things. In this assignment you will be creating

People use bags all the time for a variety of different purposes. Bags are containers that hold things. In this assignment you will be creating the abstract data type (ADT) Bag. We will begin by identifying the fundamental characteristics of all bags. We will then try to identify the fundamental operations that you would expect to be able to carry out with a bag. From these bag attributes and operations we should then be able to write a class definition for the Bag ADT.

Commonalities Bags are containers they hold thing Fundamental operations all bag objects should provide Put something in Take an item out Take everything out Count how many things are in it See if it is empty Check to see if a particular item is in it Count the number of items in it Look at all the contents

Specifications

Bags are containers they hold things

Fundamental operations with all bags

Put something in add(item)

Take an item out remove(item)

Take everything out clear()

Count how many things are in it getFrequencyOf(item)

See if it is empt isEmpty()

Check to see if something is in it contains(item)

Count the items in it getCurrentSize()

Look at all the contents display()

Program implements the Bag ADT in a manner similar to that shown below:

int main() { Bag grabBag; string item; // Test add() cout << "Enter an item "; getline(cin, item); while (item != "quit") { grabBag.add(item); cout << "Enter an item or 'quit': "; getline(cin, item); } grabBag.display(); }

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

Introductory Relational Database Design For Business With Microsoft Access

Authors: Jonathan Eckstein, Bonnie R. Schultz

1st Edition

1119329418, 978-1119329411

More Books

Students also viewed these Databases questions