Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project 1-bag directory error. So this is the instruction. I made ABag.h and BDictionary, but in the bagtestmain.cpp, it comes out with the error How

Project 1-bag directory error.

image text in transcribed

So this is the instruction.

I made ABag.h and BDictionary, but in the bagtestmain.cpp, it comes out with the error

How should I fix it without changing begtestmain.cpp???

ABag.h

#include // For using Smart Pointers #include "bagADT.h" // For inheriting from the ADT

const size_t BAG_SIZE = 10;

#pragma once template class ABag : protected Bag { private: int maxSize; int top; E* bag; public:

ABag(size_t size = BAG_SIZE) { maxSize = size; top = 0; bag = new E[maxSize]; } ~ABag() { delete[] bag; }

bool addItem(const E& item) { if (top != maxSize) { bag[top++] = item; return true; } else { return false; } }

bool remove(E& item) { bool isFound = false; for (int i = 0; i

bool removeTop(E& returnValue) { if (top != 0) { returnValue = bag[--top]; return true; } else { return false; } }

bool find(E& returnValue) const { bool isFound = false; for (int i = 0; i

bool inspectTop(E& item) const { if (top != 0) { item = bag[top - 1]; return true; } else { return false; } }

void emptyBag() { top = 0; }

bool operator+=(const E& addend) { return addItem(addend); }

int size() const { return top; }

int bagCapacity() const { return maxSize; } };

++++++++++++++++++++++++++

BDicitonary.h

#ifndef BDICTIONARY_H #define BDICTIONARY_H

#include "ABag.h" #include "kvpair.h" #include "dictionaryADT.h" #include

#pragma once template class BDictionary : public Dictionary { private: ABag>* bag; public: BDictionary(int size = defaultSize) { bag = new ABag>(size); } ~BDictionary() { delete bag; }

// Reinitialize dictionary void clear() { bag->emptyBag(); }

bool insert(const Key& k, const V& v) { std::unique_ptr> temp = std::make_unique>(k, v); return bag->addItem(*temp); }

bool remove(const Key& k, V& rtnVal) { std::unique_ptr> temp = std::make_unique>(k, rtnVal); bool isFound = bag->remove(*temp); if (isFound) { rtnVal = temp->value(); } return isFound; }

bool removeAny(V& returnValue) { std::unique_ptr> temp = std::make_unique>(); bool isRemoved = bag->removeTop(*temp); if (isRemoved) { returnValue = temp->value(); } return isRemoved; }

bool find(const Key& k, V& returnValue) const { std::unique_ptr> temp = std::make_unique>(k, returnValue); bool isFound = bag->find(*temp); if (isFound) { returnValue = temp->value(); } return isFound; }

//Returning int size() { return bag->size(); } };

#endif

image text in transcribed

Implement a dictionary using a Bag-Project 4.7 in the text (modified) Use the bag ADT provided to create an array or vector-based implementation for bags. Then use your bag to implement the dictionary ADT provided you. The bag your dictionary uses to store its values must be of type KVpair. For example, "ABag > dictionary;" is an example of an instantiation of a bag that stores KV pair types. DO NOT MAKE ANY CHANGES TO THE ADT FILES! The ADT files you submit with your assignment must match EXACTLY the files I have provided, or you will not get any credit for the assignment. To get full credit for the assignment you must incorporate one or more smart pointers and tell me where they are in your Approach document - if you make me look for them you won't get credit for them. If you don't know what smart pointers are then you'll need to do some research. Test your bag and dictionary implementations with the bagtestmain.cpp file I've provided for you. If you are not able to fully implement all the functions of the dictionary and/or bag, you may modify the tests in bagtestmain.cpp to only exercise those functions you were able to complete. You will only get credit for those methods you test and display, so be sure you don't leave any out. Also, you cannot add any public functions to your bag and dictionary implementations beyond those specified in the ADTs. This assignment (and all the following assignments) must be submitted using Visual Studios 2022 Community. Submit to Canvas your entire Visual Studios project directory as a zip file which should include all the following files: - ABag.h //Your bag-array implementation which must inherit the Bag class - BDictionary.h // Your Dictionary-bag implementation which must inherit the // Dictionary class - bagtestmain.cpp // The test driver I have provided for you - bagADT.h // The bag ADT I gave you - it should be unchanged - dictionaryADT.h // The dictionaryADT I gave you - it should be unchanged - kvpair.h // The kvpair class I gave you - it should be unchanged - Your_dictionary.exe //Your executable file. Also include in your zip file

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_2

Step: 3

blur-text-image_3

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

Advances In Databases 11th British National Conference On Databases Bncod 11 Keele Uk July 7 9 1993 Proceedings Lncs 696

Authors: Michael F. Worboys ,Anna F. Grundy

1993rd Edition

3540569219, 978-3540569213

More Books

Students also viewed these Databases questions

Question

Why? What will be my payoff?

Answered: 1 week ago

Question

Analyze the impact of labor unions on health care.

Answered: 1 week ago

Question

Assess three motivational theories as they apply to health care.

Answered: 1 week ago

Question

Discuss the history of U.S. labor unions.

Answered: 1 week ago