Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include /** * Construct an empty DataStore. */ DataStore::DataStore() { // TODO: Handle any default initialization you need here. } /** * Construct a

image text in transcribedimage text in transcribedimage text in transcribed

#include #include

/** * Construct an empty DataStore. */ DataStore::DataStore() { // TODO: Handle any default initialization you need here. }

/** * Construct a DataStore that was saved to a file. * @param filename - name of file containing data to load. */ DataStore::DataStore(std::string filename) { // TODO: Read your output file into your program. // This cannot be done until you decide how you want to // format your file. }

/** * Destructor: cleanup any allocated memory. */ DataStore::~DataStore() { // TODO: Complete the destructor. // Note: you may remove this entirely (here and in .hpp) if your data is // stored entirely in automatic variables. }

/** * Add a value to our storage. * @param value - The value to add. */ void DataStore::add_value(const int& value) { // TODO: Complete add_value. }

/** * Remove a value from storage, if it exists. * @param value - The value to remove. * @return true if the value was successfully removed and * false otherwise. */ bool DataStore::remove_value(const int& value) { // TODO: Complete remove_value. return false; }

/** * Get the number of entries for a particular value. * @param value - The value to count occurrences of. * @return The number of times the value was entered. */ int DataStore::get_count(const int& value) { // TODO: Complete get_count. return -1; }

/** * Create a space separated string of stored data as a single line. */ std::string DataStore::to_string() { // TODO: Complete write_out to std output. return ""; }

/** * Write out the data stored to a file. * @param filename - The name of the file to write to. */ void DataStore::write_out(std::string filename) { // TODO: Complete write_out to file.

Please use vector as the storage, thanks

Please use vector as the storage, thanks

.h file

#ifndef _DATA_STORE_HPP_ #define _DATA_STORE_HPP_

#include class DataStore {

public: /** * Construct an empty DataStore. */ DataStore();

/** * Construct a DataStore that was saved to a file. * @param filename - name of file containing data to load. */ DataStore(std::string filename); /** * Destructor: cleanup any allocated memory. */ ~DataStore(); /** * (disabled) Copy constructor -- create a new object as a copy of another. */ DataStore(const DataStore& other) = delete; /** * (disabled) Copy assignment -- copy another object into this object. */ DataStore& operator=(const DataStore& rhs) = delete; /** * (disabled) Move constructor -- create a new object with the data of another. */ DataStore(DataStore&& other) = delete; /** * (disabled) Move assignment -- move data from other object to this object. */ DataStore& operator=(DataStore&& rhs) = delete;

/** * Add a value to our storage. * @param value - The value to add. */ void add_value(const int& value);

/** * Remove a value from storage, if it exists. * @param value - The value to remove. * @return true if the value was successfully removed and * false otherwise. */ bool remove_value(const int& value);

/** * Get the number of entries for a particular value. * @param value - The value to count occurrences of. * @return The number of times the value was entered. */ int get_count(const int& value);

/** * Create a space separated string of stored data as a single line. */ std::string to_string();

/** * Write out the data stored to a file. * @param filename - The name of the file to write to. */ void write_out(std::string filename); };//DataStore

#endif

4.2 Programming Problem Complete the following programming assignment and submit your answers to Autolab via the "Al Progranm ming" assignment. Submit your solution in a single archive (only .zip or .tar will be accepted) Expect this section to take 15-20 hours of setting up your environment, reading through documen- tation and base code, and planning, coding, and testing your solution. Problem 2. (80 points) Your task is to build a system to store data as it is provided through a sequence of additions and removals One feature of this system is to save the data to disk in order to load it at a later point in time. For your designed, you w have to implement the sepcified API in order to provide required functionality, but the internal storage and saved file format are left for you to decide. One thing to note is that you should aim to be efficient in your design To realize this system, you will need to complete the class definition for DataStore by completing the following method definitions Constructor DataStore : :DataStore() - perform any default initialization necessary Note: this is dependant on your implementation. If you are not using anything that needs allo- cation, then this will likely be left empty. Constructor DataStore:: DataStore (std::string filename); - initialize the data store to the values stored in the file filename Destructor DataStore: :~DataStore(); - cleanup any allocated memory Note: this is dependant on your implementation. If you are not using anything that needs deal location, then this will likely be left empty .void DataStoreadd value (const int &) record the value in value into your data store the same value may be added numerous times bool DataStore::remove_value (const int& value) - if the value was not previously added, return false, otherwise remove all records of the value in value from your data store and return true - E.g., the following code should print out the value 0: DataStore storage; storage.add value (5) storage.add value (5); storage.add value (5) storage.remove_value (5) std::cout

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

Build It For The Real World A Database Workbook

Authors: Wilson, Susan, Hoferek, Mary J.

1st Edition

0073197599, 9780073197593

More Books

Students also viewed these Databases questions

Question

Differentiate between HR metrics and HR analytics.

Answered: 1 week ago