c++ Data structure

profiletatanga
DSExam1Project.zip

DS Exam 1 Project/Exam.sln

Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.27703.2042 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Exam", "Exam\Exam.vcxproj", "{DF0BD76E-0DDC-4B9A-8B63-9E93902106ED}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {DF0BD76E-0DDC-4B9A-8B63-9E93902106ED}.Debug|x64.ActiveCfg = Debug|x64 {DF0BD76E-0DDC-4B9A-8B63-9E93902106ED}.Debug|x64.Build.0 = Debug|x64 {DF0BD76E-0DDC-4B9A-8B63-9E93902106ED}.Debug|x86.ActiveCfg = Debug|Win32 {DF0BD76E-0DDC-4B9A-8B63-9E93902106ED}.Debug|x86.Build.0 = Debug|Win32 {DF0BD76E-0DDC-4B9A-8B63-9E93902106ED}.Release|x64.ActiveCfg = Release|x64 {DF0BD76E-0DDC-4B9A-8B63-9E93902106ED}.Release|x64.Build.0 = Release|x64 {DF0BD76E-0DDC-4B9A-8B63-9E93902106ED}.Release|x86.ActiveCfg = Release|Win32 {DF0BD76E-0DDC-4B9A-8B63-9E93902106ED}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {37FF8DE3-04E8-4001-994B-1C00169E6D1D} EndGlobalSection EndGlobal

DS Exam 1 Project/Exam/Exam.vcxproj

Debug Win32 Release Win32 Debug x64 Release x64 15.0 {DF0BD76E-0DDC-4B9A-8B63-9E93902106ED} Lecture2 10.0 Exam Application true v142 MultiByte Application false v142 true MultiByte Application true v142 MultiByte Application false v142 true MultiByte Level3 Disabled true true Level3 Disabled true true Level3 MaxSpeed true true true true true true Level3 MaxSpeed true true true true true true

DS Exam 1 Project/Exam/Exam.vcxproj.filters

{4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hh;hpp;hxx;hm;inl;inc;ipp;xsd {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms Source Files Source Files Header Files

DS Exam 1 Project/Exam/Exam.vcxproj.user

DS Exam 1 Project/Exam/filter.cpp

DS Exam 1 Project/Exam/filter.cpp

/*
 * Name: YOUR NAME
 * Filter Member Function Definitions
 * Course: CSI218 (Fall 2020)
 * Date: October 27, 2020
 * Description: Filter member function definitions.
 */

#ifndef  FILTER_CPP
#define  FILTER_CPP

#include   < iostream >
#include   < string >
#include   "filter.h"
using   namespace  std ;

// Filter member function definitions.

// Constructor to give size of data as well as text
// to display for data that is filtered out.
template < class  T >
Filter < T >:: Filter ( int  size ,   const  string &  initBlockStr )
{
    blockedStr  =  initBlockStr ;    // text to show for filtered data
    capacity  =  size ;              // size of array needed for data
    data  =   new  T [ capacity ];       // allocate dynamic array
    numData  =   0 ;                  // no data stored yet
}


// Accessors

// Display all data, except that value passed here
// will be filtered out (instead displayed with text
// passed to constructor).
template < class  T >
void   Filter < T >:: display ( const  T &  filterVal )   const
{
     for   ( int  i  =   0 ;  i  <  numData ;  i ++ )
     {
         if   ( data [ i ]   ==  filterVal )
            cout  <<  blockedStr ;
         else
            cout  <<  data [ i ];
        cout  <<   " " ;    // space between
     }
    cout  <<  endl ;
}

// Add value to end of existing stored data.
// Precondition: must be room for more data in array.
template < class  T >
void   Filter < T >:: add ( const  T &  val )
{
     // FILL IN FUNCTION

}

#endif

DS Exam 1 Project/Exam/filter.h

/* * Name: YOUR NAME * Filter Class Definition * Course: CSI218 (Fall 2020) * Date: October 27, 2020 * Description: Filter template class definition declaring * data members and member functions for type "T". */ // Filter template class definition with data members and // prototypes for member functions. #ifndef FILTER_H #define FILTER_H #include <string> using namespace std; template<class T> class Filter { public: // Constructor to give size of data as well as text // to display for data that is filtered out. Filter(int size, const string& initBlockStr); // Copy constructor //Filter(const Filter<T>& otherFilter); // Assignment operator //Filter<T>& operator =(const Filter<T>& otherFilter); // Display all data, except that value passed here // will be filtered out (instead displayed with text // passed to constructor). void display(const T& filterVal) const; // Add value to end of existing stored data. // Precondition: must be room for more data in array. void add(const T& val); private: T *data; // pointer for dynamic array storing filterable data int capacity; // size of array int numData; // # of pieces of data stored in array string blockedStr; // text to show for data that is filtered out }; #endif

DS Exam 1 Project/Exam/main.cpp

DS Exam 1 Project/Exam/main.cpp

/*
 * Name: YOUR NAME
 * Exam 1 Project
 * Course: CSI218 (Fall 2020)
 * Date: October 27, 2020
 * Description: Filter out certain information from data
 *              to avoid revealing internal secrets of an
 *              organization.
 */

#include   < iostream >
#include   < iomanip >    // for manipulators with arguments
#include   < string >
#include   < vector >
#include   "filter.cpp"    // Filter template class
using   namespace  std ;

// Function to place all values from vector of strings in filter object
// so that certain values can be blocked from view on output.
void  addValues ( Filter < string >&  filter ,   const  vector < string >&  document );

int  main ()
{
     // Information about a business deal.
     const  vector < string >  DOCUMENT
         =   {   "Company" ,   "sold" ,   "patent" ,   "to" ,   "Google" ,
             "for" ,   "special" ,   "machine" ,   "instruction" ,
             "01101110"   };

     // Allow filtering of document to block certain information
     // from being revealed.
     Filter < string >  redactedDoc ( DOCUMENT . size (),   "XXX" );

     // Add all the information in documents to filter objects.
    addValues ( redactedDoc ,  DOCUMENT );

     // Ask user what value want to filter from documents.
     do
     {
        cout  <<   "\nEnter value to filter from document (blank=end): " ;
        string filterValue ;
        getline ( cin ,  filterValue );

         if   ( filterValue  ==   "" )    // exit filtering?
             break ;

         // Display filtered document.
        redactedDoc . display ( filterValue );

     }   while   ( true );

     return   0 ;
}

// Function to place all values from vector of strings in filter object
// so that certain values can be blocked from view on output.
void  addValues ( Filter < string >&  filter ,   const  vector < string >&  document )
{
     // FILL IN FUNCTION
}