Question

In: Computer Science

Act 1: Class BooleanFunc Overview BooleanFunc will contain a truthTable (a dynamic array) which defines the...

Act 1: Class BooleanFunc

Overview

BooleanFunc will contain a truthTable (a dynamic array) which defines the boolean function being represented. You can load this truthTable using a mutator, setTruthTable() , and change the function it represents by calling setTruthTable() to give the table new values. You will not be able to change the size of the table (i..e. #inputs to the function) after an object is instantiated using a setTableSize-style method, but you can totally redefine the object using the assignment operator, which will have the effect of giving it a new size. You will need a method to evaluate the state (output) of the function based on input integers, and this will take the form or an eval( int ) method. Finally, you will store the most recently evaluated output in an internal bool state member, so you can call eval() once, but get the resulting state later without having to re-call eval(): a method getState() will do the job nicely.

Static (Public) Members

  • int MAX_TABLE_FOR_CLASS = 65536; // 2^16 ~ 16 binary input lines
  • int DEFAULT_TABLE_SIZE = 16

Instance (Private) Members

  • int tableSize - reflects the number of inputs. tableSize of 4 would imply two binary inputs; a size of 16 would imply four binary inputs. Since you will be using one int to act as your multi-bit input, a tableSize of 4 means the valid input ints are 0-3. Size of 16 means valid input ints are 0-15.
  • bool *truthTable - This is your array (to be dynamically allocated and de-allocated) whose size is tableSize.
  • bool evalReturnIfError - This is the state (or return value) if an illegal (out-of-range) input is presented to the object -- or if no input has yet been presented to it.
  • bool state - this remembers the result of the most recent call to eval( int ).

Instance (Public) Methods

  • Constructors and a Destructor - The constructor's signature should be BooleanFunc( int tableSize = DEFAULT_TABLE_SIZE, bool evalReturnIfError = false ). More on constructors, below.
  • Mutators - You set the truth table not by passing an array which is an exact copy of the function table. Rather, you choose one of two mutators:
    • bool setTruthTableUsingTrue( int inputsThatProduceTrue[], int arraySize ) - In other words, if the function evaluates to true only for inputs 3 and 9, you would send it an array {3, 9} of size 2. This way, even if the table is very large, you can easily set it by passing a very small array in the cases where very few inputs produce true outputs. Any indices not passed in the array parameter are assumed to represent false outputs for their respective table positions.
    • bool setTruthTableUsingFalse( int inputsThatProduceFalse[], int arraySize ) - If the most common output is true, however, then you might prefer to use this method which has the same signature as its partner but provides an array whose values represent the false-triggering inputs. For example, if the truth table had size 64, and you wanted to represent a function "greater than 3", we would use setTruthTableUsingFalse(), and send it the array {0, 1, 2, 3}. Any indices not passed in the array parameter are assumed to represent true outputs for their respective table positions.
    • The return value of these two methods is true as long as the passed-in array size is <= the truth table array, and false, otherwise.. However, if a bad int is passed inside the array parameter (e.g., {5, 0, 2, 19} in the case of a 16-element truth table), you will just ignore the bad int (19) and process the other good ints that are passed (5, 0 and 2).
  • bool eval( int input ) and bool getState() - a mutator for the state member based on the an input integer, which also returns that evaluated state, and an accessor for the state. If an invalid input is presented to eval(), evalReturnIfError is assigned to state and returned.
  • Deep memory methods - A copy constructor, destructor and assignment operator.

Supply helper methods as appropriate.

Testing Specification Act 1

Sample Client

Here is some client code to use while debugging. You should be able to determine the correct run that results. You should provide some code that is more complete than this in your testing.

   BooleanFunc segA, segB( 13 ), segC( 100, true );

   int evenFunc[] = { 0, 2, 4, 6, 8, 10, 12, 14 }, inputX;
   short sizeEvenFunc = sizeof(evenFunc) / sizeof(evenFunc[0]);

   int greater9Func[] = { 10, 11, 12, 13, 14, 15 };
   short sizeGreater9Func = sizeof(greater9Func) / sizeof(greater9Func[0]);

   int greater3Func[] = { 0, 1, 2, 3 };
   short sizeGreater3Func = sizeof(greater3Func) / sizeof(greater3Func[0]);

   segA.setTruthTableUsingTrue( evenFunc, sizeEvenFunc );
   segB.setTruthTableUsingTrue( greater9Func, sizeGreater9Func );
   segC.setTruthTableUsingFalse( greater3Func, sizeGreater3Func );

   // testing class BooleanFunc
   cout << "before eval()\n";
   cout
      << "\n  A(x) = "
      << segA.getState()
      << "\n  B(x) = "
      << segB.getState()
      << "\n  C(x) = "
      << segC.getState()
      << endl << endl;
   cout << "looping with eval()\n";
   for ( inputX = 0; inputX < 10; inputX++ )
   {
      segA.eval( inputX );
      segB.eval( inputX );
      segC.eval( inputX );
      cout
         << "Input: " << inputX
         << "\n  A(x) = "
         << segA.getState()
         << "\n  B(x) = "
         << segB.getState()
         << "\n  C(x) = "
         << segC.getState()
         << endl << endl;
   }
   segA.eval( inputX );

Act 2: Class MultiSegmentLogic

Overview

MultiSegmentLogic encapsulates any number of segments as a dynamic array of BooleanFunc objects and allows them to work together to produce some multi-segment display. Upon instantiation, a MultiSegmentLogic object obtains its size (the number of segments) from the user. This can be changed (a major resetting of the object) through the mutator setNumSegs(). After construction, or a resetting of the object via setNumSegs(), the truth table for each segment needs to be loaded, which is done using mutator setSegment(). setSegment() sends a BooleanFunc to a particular segment. For a seven segment display this would have to be called seven times, once for each segment. You will do that in the derived class (Act 3), not in the client.

Static (Public) Members

(None are needed.)

Instance (Protected) Members

  • int numSegs - the number of BooleanFuncs (i.e., segments) that this potential display logic encapsulates. We think of this as being 7, but it can be any positive int.
  • BooleanFunc *segs - This is our array (to be dynamically allocated and de-allocated) whose size is numSegs.

Instance (Public) Methods

  • Constructors and a Destructor - The constructor's signature should be MultiSegmentLogic( int numSegs = 0 ). It has to allocate an array of numSegs BooleanFuncs. More on constructors, below.
  • Mutators - One that sets the number of segments and one that loads the truth table for a particular segment:
    • bool setNumSegs( int numSegs ) - this is a fairly serious mutator, which must completely redefine the kind of display, wiping out old segments and reallocating the new number of segments, leaving each in a default state. This is called, for example, when changing from a 7 segment to 12 segment display. Any non-negative value is allowed.
    • bool setSegment( int segNum, BooleanFunc &funcForThisSeg ) - it sets segs[segNum] to the passed-in BooleanFunc. It filters bad segNum and takes appropriate action.
  • void eval( int input ) - calls eval() for each of the segs in the object.
  • Deep memory methods - A copy constructor, destructor and assignment operator.

Supply helper methods as appropriate.

Testing Specification Act 2

Sample Client

You can create and test your own sample client, but not to hand it in. I want to see the sample client of the derived class, SevenSegmentLogic, which will implicitly test MultiSegmentLogic.

Act 3: Derived Class SevenSegmentLogic

Overview

This class is derived from MultiSegmentLogic. It has no new members but adds the specifics of seven segment display logic, namely the number of segments (= 7) and the actual truth tables for a seven-segment display.

Static (Public) Members

(None are needed.)

Instance (Protected) Members

(None are needed.)

Instance (Public) Methods

  • Default Constructor - Simply sets the number of segments to 7 (literal ok) and the loads the BooleanFuncs for each of the seven segments using a helper (see below).
  • bool getValOfSeg( int seg ) - Returns whatever is in the state variable of that segment. Of course checks for valid parameter.

Helper methods

You will need some private helpers to load the segments, called somewhere in the constructor.   Ultimately, somewhere you will need to call setSegment( k, bFunc) for k = 0 through 6, where bFunc is the boolean function for the kth segment. For example, if a, b, c, d, e, f and g, are the universal names for the segments, let's say that you associate segs[0] ↔ a, segs[1] ↔ b, segs[2] ↔ c and so on.    The boolean function for segment a (your segs[0]) is easily found along with all the others, on-line. Here is the truth table for segment a:

"a" bit (7-segment display)
input output
0 T
1 F
2 T
3 T
4 F
5 T
6 T
7 T
8 T
9 T
10 T
11 F
12 T
13 F
14 T
15 T

You would, therefore, instantiate a BooleanFunc that realizes this truth table (using the BooleanFunc mutator setTruthTableUsing...()) then pass that BooleanFunc object to the setSegment() method of the base class. All of this is done in the helper function.

Testing Specification Act 3

Here is some client code use while debugging. You should be able to determine the correct run that results. You should provide some code that is more complete than this in your testing. This example tests the copy constructor as well as the other methods.

   int inputX, k;
   SevenSegmentLogic my7Seg;
   SevenSegmentLogic myCopy( my7Seg );

   for ( inputX = 0; inputX < 16; inputX++ )
   {
      myCopy.eval( inputX );
      cout << "\n| ";
      for ( k = 0; k < 7; k++ )
         cout << myCopy.getValOfSeg( k ) << " | ";
      cout << endl;
   }

What to Turn In

Hand in 5 files: No zip files.

  • boolean.h
  • boolean.cpp
  • logic.h
  • logic.cpp
  • a7.cpp : test driver file

Solutions

Expert Solution

Below is complete code. Please note that Act3 requires additional class files that i have added, if you do not require them in your assignment just ignore them. Let me know if you have any proble or doubt. Thank you.

=====================================================================

boolean.h

=========================

#ifndef BOOLEAN_H
#define BOOLEAN_H

class BooleanFunc
{
private:
    int tableSize; // size of truth table
    bool* truthTable; // array to represent truth table
    bool evalReturnIfError; // flag to check error present in input
    bool state; // result of the most recent call to eval(int)
public:
    static const int MAX_TABLE_FOR_CLASS = 65536; // 2^16 ~ 16 binary input lines
    static const int DEFAULT_TABLE_SIZE = 16;
    BooleanFunc(int tableSize = DEFAULT_TABLE_SIZE, bool evalReturnIfError = false); // constructor
    ~BooleanFunc(); // destructor
    BooleanFunc(const BooleanFunc& other); // copy constructor
    // assignment operator
    void operator=(const BooleanFunc& other);
    // Mutators
    bool setTruthTableUsingTrue(int inputsThatProduceTrue[], int arraySize);
    bool setTruthTableUsingFalse(int inputsThatProduceFalse[], int arraySize);
    // evaluates next state for given input
    bool eval(int input);
    // returns last evaluated state
    bool getState() const;
};

#endif // !BOOLEAN_H

=========================

boolean.cpp

=========================

#include "boolean.h"

BooleanFunc::BooleanFunc(int tableSize, bool evalReturnIfError)
{
   // initialize data
   this->tableSize = tableSize;
   this->evalReturnIfError = evalReturnIfError;
   this->state = evalReturnIfError; // default state is no input present
   // dynamicly allocate array
   this->truthTable = new bool[tableSize];
   // initialize truth table to false for all inputs
   for (int i = 0; i < tableSize; i++)
   {
       this->truthTable[i] = false;
   }
}

BooleanFunc::~BooleanFunc()
{
   // delete array to free memory
   delete[] truthTable;
}

BooleanFunc::BooleanFunc(const BooleanFunc& other)
{
   // use assignment operator to deep copy current object
   *this = other;
}

void BooleanFunc::operator=(const BooleanFunc& other)
{
   // check for self assignment
   if (this == &other) {
       return;
   }
   // copy values form other
   this->tableSize = other.tableSize;
   this->evalReturnIfError = other.evalReturnIfError;
   this->state = other.state;
   // delete old array
   delete[] this->truthTable;
   // create new array
   this->truthTable = new bool[tableSize];
   // copy truth tale
   for (int i = 0; i < this->tableSize; i++)
   {
       this->truthTable[i] = other.truthTable[i];
   }
}

bool BooleanFunc::setTruthTableUsingTrue(int inputsThatProduceTrue[], int arraySize)
{
   // set truth table only if array size is valid
   if (arraySize > tableSize)
   {
       return false;
   }
   // initialize truth table to false for all inputs
   for (int i = 0; i < tableSize; i++)
   {
       this->truthTable[i] = false;
   }
   // set all entries in truth table within array as true
   for (int i = 0; i < arraySize; i++)
   {
       // filter bad inputs and ignore them
       if (inputsThatProduceTrue[i] < tableSize)
       {
           this->truthTable[inputsThatProduceTrue[i]] = true;
       }
   }
   return true;
}

bool BooleanFunc::setTruthTableUsingFalse(int inputsThatProduceFalse[], int arraySize)
{
   // set truth table only if array size is valid
   if (arraySize > tableSize)
   {
       return false;
   }
   // initialize truth table to true for all inputs
   for (int i = 0; i < tableSize; i++)
   {
       this->truthTable[i] = true;
   }
   // set all entries in truth table within array as false
   for (int i = 0; i < arraySize; i++)
   {
       // filter bad inputs and ignore them
       if (inputsThatProduceFalse[i] < tableSize)
       {
           this->truthTable[inputsThatProduceFalse[i]] = false;
       }
   }
   return true;
}

bool BooleanFunc::eval(int input)
{
   // check for valid input
   if (input < tableSize)
   {
       // set new state to remember last eval
       state = truthTable[input];  
   }
   else
   {
       // input contains error
       // set new state to default value for errors
       state = evalReturnIfError;
   }
   // return new state
   return getState();
}

bool BooleanFunc::getState() const
{
   return state;
}

=========================

logic.h

=========================

#include "boolean.h"

#ifndef LOGIC_H
#define LOGIC_H

class MultiSegmentLogic {
protected:
    int numSegs; // the number of BooleanFuncs
    BooleanFunc* segs; // array to represent logic segments
public:
    MultiSegmentLogic(int numSegs = 0); // constructor
    ~MultiSegmentLogic(); // destructor
    MultiSegmentLogic(const MultiSegmentLogic& other); // copy constructor
    // assignment operator
    void operator=(const MultiSegmentLogic& other);
    // Mutators
    bool setNumSegs(int numSegs);
    bool setSegment(int segNum, BooleanFunc& funcForThisSeg);
    void eval(int input); // calls eval() for each of the segs in the object.
};

#endif // !LOGIC_H

=========================

logic.cpp

=========================

#include "logic.h"

MultiSegmentLogic::MultiSegmentLogic(int numSegs)
{
   // initialize data
   this->numSegs = numSegs;
   this->segs = new BooleanFunc[numSegs];
}

MultiSegmentLogic::~MultiSegmentLogic()
{
   // delete array to free memory
   delete[] segs;
}

MultiSegmentLogic::MultiSegmentLogic(const MultiSegmentLogic& other)
{
   // use assignment operator to deep copy current object
   *this = other;
}

void MultiSegmentLogic::operator=(const MultiSegmentLogic& other)
{
   // check for self assignment
   if (this == &other) {
       return;
   }
   // copy data from other
   this->numSegs = other.numSegs;
   // delete old array
   delete[] this->segs;
   // create new array
   this->segs = new BooleanFunc[numSegs];
   // copy segments from other
   for (int i = 0; i < numSegs; i++)
   {
       // use overloaded assignment operator to deep copy each segment
       this->segs[i] = other.segs[i];
   }
}

bool MultiSegmentLogic::setNumSegs(int numSegs)
{
   // check for valid input
   if (numSegs < 0)
   {
       return false;
   }
   // reset number of segment
   this->numSegs = numSegs;
   // delete old segments
   delete[] segs;
   // re assign array of segment in their default state
   segs = new BooleanFunc[numSegs];
   return true;
}

bool MultiSegmentLogic::setSegment(int segNum, BooleanFunc& funcForThisSeg)
{
   // check for valid segNum
   if (segNum < numSegs)
   {
       // reset given BooleanFunc
       segs[segNum] = funcForThisSeg;
       return true;
   }
   return false;
}

void MultiSegmentLogic::eval(int input)
{
   // call eval for each segment
   for (int i = 0; i < numSegs; i++)
   {
       segs[i].eval(input);
   }
}

=========================

sevenSegLogic.h

=========================

#include "logic.h"

#ifndef SEVEN_SEGMENT_LOGIC_H
#define SEVEN_SEGMENT_LOGIC_H

class SevenSegmentLogic: public MultiSegmentLogic {
private:
   void loadSegments(); // private helper function
public:
   SevenSegmentLogic(); // default constructor
   bool getValOfSeg(int seg); // Returns whatever is in the state variable of that segment
};

#endif // !SEVEN_SEGMENT_LOGIC_H

=========================

sevenSegLogic.cpp

=========================

#include "sevenSegLogic.h"

void SevenSegmentLogic::loadSegments()
{
   // get truth table for each segment
   /*
   bool a[16] = { true, false, true, true, false, true, true, true, true, true, true, false, true, false, true, true };
   bool b[16] = { true, true, true, true, true, false, false, true, true, true, true, false, false, true, false, false };
   bool c[16] = { true, true, false, true, true, true, true, true, true, true, true, true, false, true, false, false };
   bool d[16] = { true, false, true, true, false, true, true, false, true, true, true, true, true, true, true, false };
   bool e[16] = { true, false, true, false, false, false, true, false, true, false, true, true, true, true, true, true };
   bool f[16] = { true, false, false, false, true, true, true, false, true, true, false, true, true, false, true, true };
   bool g[16] = { false, false, true, true, true, true, true, false, true, true, true, true, false, true, true, true };
   */
   // create boolean function for each segment
   int a[] = { 1,4,11,13 };
   BooleanFunc segA;
   segA.setTruthTableUsingFalse(a, 4);
   int b[] = { 5,6,11,12,14,15 };
   BooleanFunc segB;
   segB.setTruthTableUsingFalse(b, 6);
   int c[] = { 2,12,14,15 };
   BooleanFunc segC;
   segC.setTruthTableUsingFalse(c, 4);
   int d[] = { 1,4,7,15 };
   BooleanFunc segD;
   segD.setTruthTableUsingFalse(d, 4);
   int e[] = { 1,3,4,5,7,9 };
   BooleanFunc segE;
   segE.setTruthTableUsingFalse(e, 6);
   int f[] = { 1,2,3,7,10,13 };
   BooleanFunc segF;
   segF.setTruthTableUsingFalse(f, 6);
   int g[] = { 0,1,7,12 };
   BooleanFunc segG;
   segG.setTruthTableUsingFalse(g, 4);

   // load individual segment
   setSegment(0, segA);
   setSegment(1, segB);
   setSegment(2, segC);
   setSegment(3, segD);
   setSegment(4, segE);
   setSegment(5, segF);
   setSegment(6, segG);
}

SevenSegmentLogic::SevenSegmentLogic() : MultiSegmentLogic(7)
{
   // initialize with 7 segments
   // load each segment
   loadSegments();
}

bool SevenSegmentLogic::getValOfSeg(int seg)
{
   // checck for valid segment and return its state
   if (seg < 7)
   {
       return this->segs[seg].getState();
   }
   return false; // error value
}

=========================

a7.cpp

=========================

#include "sevenSegLogic.h"
#include <iostream>

using namespace std;

int main() {
   // Testing Specification Act 1
    BooleanFunc segA, segB(13), segC(100, true);

    int evenFunc[] = { 0, 2, 4, 6, 8, 10, 12, 14 }, inputX;
    short sizeEvenFunc = sizeof(evenFunc) / sizeof(evenFunc[0]);

    int greater9Func[] = { 10, 11, 12, 13, 14, 15 };
    short sizeGreater9Func = sizeof(greater9Func) / sizeof(greater9Func[0]);

    int greater3Func[] = { 0, 1, 2, 3 };
    short sizeGreater3Func = sizeof(greater3Func) / sizeof(greater3Func[0]);

    segA.setTruthTableUsingTrue(evenFunc, sizeEvenFunc);
    segB.setTruthTableUsingTrue(greater9Func, sizeGreater9Func);
    segC.setTruthTableUsingFalse(greater3Func, sizeGreater3Func);

    // testing class BooleanFunc
    cout << "before eval()\n";
    cout
        << "\n A(x) = "
        << segA.getState()
        << "\n B(x) = "
        << segB.getState()
        << "\n C(x) = "
        << segC.getState()
        << endl << endl;
    cout << "looping with eval()\n";
    for (inputX = 0; inputX < 20; inputX++)
    {
        segA.eval(inputX);
        segB.eval(inputX);
        segC.eval(inputX);
        cout
            << "Input: " << inputX
            << "\n A(x) = "
            << segA.getState()
            << "\n B(x) = "
            << segB.getState()
            << "\n C(x) = "
            << segC.getState()
            << endl << endl;
    }

    // Testing Specification Act 3
    int k;
    SevenSegmentLogic my7Seg;
    SevenSegmentLogic myCopy(my7Seg);

    for (inputX = 0; inputX < 16; inputX++)
    {
        myCopy.eval(inputX);
        cout << "\n| ";
        for (k = 0; k < 7; k++)
            cout << myCopy.getValOfSeg(k) << " | ";
        cout << endl;
    }

    // here code for printing seven segment logic for LED number
    for (int i = 0; i < 10; i++)
    {
        my7Seg.eval(i);
        for (int j = 1; j < 16; j++)
        {
            // print emplty space
            if (j % 2 != 0)
                cout << " ";
            // print LED lines
            else if (j == 2 && my7Seg.getValOfSeg(0))
                cout << "-";
            else if (j == 4 && my7Seg.getValOfSeg(5))
                cout << "|";
            else if (j == 6 && my7Seg.getValOfSeg(1))
                cout << "|";
            else if (j == 8 && my7Seg.getValOfSeg(6))
                cout << "-";
            else if(j == 10 && my7Seg.getValOfSeg(4))
                cout << "|";
            else if(j == 12 && my7Seg.getValOfSeg(2))
                cout << "|";
            else if(j == 14 && my7Seg.getValOfSeg(3))
                cout << "-";
            else
                cout << " ";
            // print new lines
            if (j % 3 == 0)
                cout << endl;
        }
        cout << endl;
    }
  
   return 0;
}

=====================================================================


Related Solutions

IN C++ (THIS IS A REPOST) Design a class, Array, that encapsulates a fixed-size dynamic array...
IN C++ (THIS IS A REPOST) Design a class, Array, that encapsulates a fixed-size dynamic array of signed integers. Write a program that creates an Array container of size 100 and fills it with random numbers in the range [1..999]. (Use std::rand() with std::srand(1).) When building the array, if the random number is evenly divisible by 3 or 5, store it as a negative number. Within your main.cpp source code file, write a function for each of the following processes....
Implement in C++ Design a BookstoreManager class which creates a dynamic array of type Book (don’t...
Implement in C++ Design a BookstoreManager class which creates a dynamic array of type Book (don’t use vectors), and provide an implementation for the following operations on books in the array 1)isEmpty() returns true if the array is empty, otherwise false 2)isFull() returns true if the array is full, otherwise false 3)listSize() prints the number of books in the array 4)print() prints the content of the array 5)insert(Book) asks the user to enter new book info, and it adds the...
Implement in C++ Design a BookstoreManager class which creates a dynamic array of type Book (don’t...
Implement in C++ Design a BookstoreManager class which creates a dynamic array of type Book (don’t use vectors), and provide an implementation for the following operations on books in the array 1)isEmpty() returns true if the array is empty, otherwise false 2)isFull() returns true if the array is full, otherwise false 3)listSize() prints the number of books in the array 4)print() prints the content of the array 5)insert(Book) asks the user to enter new book info, and it adds the...
Implement a class Polynomial that uses a dynamic array of doubles to store the coefficients for...
Implement a class Polynomial that uses a dynamic array of doubles to store the coefficients for a polynomial. Much of this work can be modelled on the C++ dynamic array of ints List that we discussed in class. This class does not need the method the overloaded += operator. Your class should have the following methods: Write one constructor that takes an integer n for the degree of a term and a double coefficient c for the coefficient of the...
For this assignment you will implement a dynamic array. You are to build a class called...
For this assignment you will implement a dynamic array. You are to build a class called MyDynamicArray. Your dynamic array class should manage the storage of an array that can grow and shrink. The public methods of your class should be the following: MyDynamicArray(); Default Constructor. The array should be of size 2. MyDynamicArray(int s); For this constructor the array should be of size s. ~MyDynamicArray(); Destructor for the class. int& operator[](int i); Traditional [] operator. Should print a message...
write a c++ program. Define a class ‘Matrix’ which contain 2D int array ‘m’ of size...
write a c++ program. Define a class ‘Matrix’ which contain 2D int array ‘m’ of size 3x3 as private member.        There should be two public methods within the class definition namely: void setMatrixValue(int i, int j); that should set m[i][j] with user defined values int getMatrixValue(int i, int j); that should return m[i][j] Make a global function named ‘CrossProduct(Matrix m1, Matrix m2)’ that should compute the marix multiplication
For this lab you will continue your dynamic array by completing the class called MyDynamicArray. The...
For this lab you will continue your dynamic array by completing the class called MyDynamicArray. The MyDynamicArray class should manage the storage of an array that can grow and shrink. The public methods of your class should already be the following: MyDynamicArray(); Default Constructor. The array should be of capacity 2. MyDynamicArray(int s); For this constructor the array should be of capacity and size s. int& operator[](int i); Traditional [] operator. Should print a message if i is out of...
Procedural law defines the conditions under which justice actors must act. Substantive law defines crime and...
Procedural law defines the conditions under which justice actors must act. Substantive law defines crime and punishment for that crime. Which of these - procedural or substantive - do we emphasize in our constitution and why would we have made that choice?
Write a code in c++ using dynamic array of structure and dynamic array list. Make a...
Write a code in c++ using dynamic array of structure and dynamic array list. Make a dummy list for a company which stores following information about its customers. Customer ID Customer Name Gender Total items purchased Item category 20% discount in percentage of total purchase amount. Use dynamic array to save at least 20 items by dividing them into 3 different categories. Make a dummy list of items that company sells by dividing them into two categorizes. Items has following...
Define the classes to complete dynamic array hierarchy with a concrete, abstract and interface class. public...
Define the classes to complete dynamic array hierarchy with a concrete, abstract and interface class. public class DArray { private int array[]; public DArray() { } private void expandArray() { } private void shrinkArray() { } } --------------------------------------------------------------- public abstract class ArrayBP { protected int numElements; protected int numAllocations; public abstract void storeAt(int item, int index) { } public abstract getFrom(int index) { } public abstract int len() { } public abstract void remove();{ } public abstract void removeAt(int index)...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT