Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Description: Dual - Scripted Array Class in C + + . I have one header file. now I have to make another file in which
Description: DualScripted Array Class in C I have one header file. now I have to make another file in which I have to Satisfy all the requirements of the question. In the third file which contains main function which is the test drive file in which I have to test all the functionality of the program. I want to make a running program which satisfy all the requirements in C Create class DSArray DualScripted Array Please name the class DSArray for consistency. The underlying abstracted memory management for DSArray should be implemented as a sparse list. That is to say, array elements are only created when accessed for the first time. When the initial DSArray object is created, the input parameters ie constructor parameters are only used to determine the maximum size of the array, but no memory is actually allocated for any array elements. A DSArray object can be of any arbitrary size, in dimensions. During development and testing, it is highly recommended that you keep it small sayx Abstraction and Encapsulation are implemented by how you represent your underlying data structure to contain only elements of the array that have been accessed. You can use ANY data structure, but keep in mind that the data structure you use needs to be dynamically adjustable; if new indexes are accessed written increase memory usage, if array is made smaller, decrease memory usage. At construction time, the DSArray class should be able to create an array of any number of elements in each of the dimensions ie number of rows and columnsie initialization constructor or provide a default size ie default constructor The DSArray class should supply operator to perform index operations. For example, in a MxN DSArray called myArray, the user could write a myArray to access the element at row column NOTE: the element myArray does not exist, and should return The first element will be myArray Provide public accessors in the form of the following overloaded operators. Please note that for Java and python you should overload the equivalent operators or methods aequality always return FALSE for differentsized arrays binequality always return TRUE for differentsized arrays cassignment The assignment operator will dynamically resize the lvalue array to the size of the rvalue array, and assign all the values of the lvalue elements to the rvalue values. dostream for outputting the array in row and column format efor accessing individual elements of the array. Note that you cannot overload the square brackets for this class, because operator allows only one parameter, whereas operator allows any number of parameters For example, in a MxN DSArray called myArray, the user could write a myArray to access the element at row column Generally, any access to a subscript out of range should throw and exception, and should be caught by the client and handled. For an MxN array, valid indexes are M and N; You must implement a ChangeSize method. This will dynamically change the size of the array in any or all dimensions. When the array is made larger in any dimension, existing elements will not be affected; only the valid index references array size will change. When the array is made smaller in any dimension, existing elements will be truncated pruned in that dimension. Implement a proper copy constructor so that it may be passed by value tofrom a function. You must implement a test driver to demonstrate that your DSArray class is working. Therefore, the test driver must have explicit output indicating proper operation. You must test ALL overloaded operators, the ChangeSize method, and the copy constructor. I have a header file DSArray.h : #ifndef TSINTARRAY #define TSINTARRAY #include #include using std::ostream; using std::istream; using std::cout; using std::endl; using std::cin; class DSArray friend ostream &operator ostream& DSArray & ; public: DSArrayint rows int cols; DSArrayconst DSArray &; ~DSArray; void changeSizeunsigned int rows, unsigned int cols; int numElements; int &operatorunsigned int row, unsigned int col; DSArray &operatorDSArray &c; bool operatorconst DSArray &c; bool operator!const DSArray &c; private: unsigned int numRows; unsigned int numColumns; ; #endif TSINTARRAY
Description: DualScripted Array Class in C I have one header file. now I have to make another file in which I have to Satisfy all the requirements of the question. In the third file which contains main function which is the test drive file in which I have to test all the functionality of the program.
I want to make a running program which satisfy all the requirements in C
Create class DSArray DualScripted Array Please name the class DSArray for consistency. The underlying abstracted memory management for DSArray should be implemented as a sparse list. That is to say, array elements are only created when accessed for the first time. When the initial DSArray object is created, the input parameters ie constructor parameters are only used to determine the maximum size of the array, but no memory is actually allocated for any array elements. A DSArray object can be of any arbitrary size, in dimensions. During development and testing, it is highly recommended that you keep it small sayx Abstraction and Encapsulation are implemented by how you represent your underlying data structure to contain only elements of the array that have been accessed. You can use ANY data structure, but keep in mind that the data structure you use needs to be dynamically adjustable; if new indexes are accessed written increase memory usage, if array is made smaller, decrease memory usage. At construction time, the DSArray class should be able to create an array of any number of elements in each of the dimensions ie number of rows and columnsie initialization constructor or provide a default size ie default constructor The DSArray class should supply operator to perform index operations. For example, in a MxN DSArray called myArray, the user could write a myArray to access the element at row column NOTE: the element myArray does not exist, and should return The first element will be myArray Provide public accessors in the form of the following overloaded operators. Please note that for Java and python you should overload the equivalent operators or methods aequality always return FALSE for differentsized arrays binequality always return TRUE for differentsized arrays cassignment The assignment operator will dynamically resize the lvalue array to the size of the rvalue array, and assign all the values of the lvalue elements to the rvalue values. dostream for outputting the array in row and column format efor accessing individual elements of the array. Note that you cannot overload the square brackets for this class, because operator allows only one parameter, whereas operator allows any number of parameters For example, in a MxN DSArray called myArray, the user could write a myArray to access the element at row column Generally, any access to a subscript out of range should throw and exception, and should be caught by the client and handled. For an MxN array, valid indexes are M and N; You must implement a ChangeSize method. This will dynamically change the size of the array in any or all dimensions. When the array is made larger in any dimension, existing elements will not be affected; only the valid index references array size will change. When the array is made smaller in any dimension, existing elements will be truncated pruned in that dimension. Implement a proper copy constructor so that it may be passed by value tofrom a function. You must implement a test driver to demonstrate that your DSArray class is working. Therefore, the test driver must have explicit output indicating proper operation. You must test ALL overloaded operators, the ChangeSize method, and the copy constructor.
I have a header file DSArray.h :
#ifndef TSINTARRAY
#define TSINTARRAY
#include
#include
using std::ostream;
using std::istream;
using std::cout;
using std::endl;
using std::cin;
class DSArray
friend ostream &operator ostream& DSArray & ;
public:
DSArrayint rows int cols;
DSArrayconst DSArray &;
~DSArray;
void changeSizeunsigned int rows, unsigned int cols;
int numElements;
int &operatorunsigned int row, unsigned int col;
DSArray &operatorDSArray &c;
bool operatorconst DSArray &c;
bool operator!const DSArray &c;
private:
unsigned int numRows;
unsigned int numColumns;
;
#endif TSINTARRAY
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started