Homework 4 - Object Oriented Programming in C++ | CIS 554, Assignments of Computer Science

Material Type: Assignment; Professor: Waclawski; Class: Object Oriented Programming in C++; Subject: Computer & Info Science; University: Syracuse University; Term: Unknown 1989;

Typology: Assignments

Pre 2010

Uploaded on 08/09/2009

koofers-user-mq3
koofers-user-mq3 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CIS 554 Homework 4
Homework Objective: Provide students with an opportunity to understand and become comfortable with
creating more complex classes, operator overloading, data structures, and memory allocation and
management. Also demonstrates use of friend functions and friend classes with tightly coupled objects.
Description: Tri-Scripted Array Class
1. Create a class TSArray (Tri-Scripted Array) that has similar features to the single-dimensioned
myIntArray class I went over. You MUST name your class TSArray. Otherwise, you will not be
able to use the IntNode class correctly.
2. TSArray 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 array is created, the input parameters (i.e. constructor
parameters) are only used to determine the maximum size of the array, but no memory is actually
allocated for any array elements when a TSArray object is created.
3. The TSArray class will be composed of a singly linked list class as its underlying storage
implementation of the sparse list. At construction time, the TSArray class should be able to create an
array of any number of elements in each of the dimensions (i.e. number of rows, columns and depth).
You will use the NodeSLList class I have provided on the web as your linked list
4. The TSArray class should supply operator() to perform tri-scripting operations. For example, in a
MxNxO TSArray called myArray, the user could write myArray(1,2,3) to access the element at
row 1, column 2, depth 3. Note that myArray(0,0,0) does not exist, and should return 0. The first
element will be myArray(1,1,1). Remember that operator() can receive any number of arguments.
(see class String in Figure 11.9 thru Figure 8.11 for an example of operator()).
5. The class should also provide the following operators. You must provide rational behavior for each
operator. The assignment operator will dynamically re-size the lvalue array to the size of the rvalue
array, and assign all the values of the lvalue elements to the rvalue values.
= = (equality – always return FALSE for different-sized arrays)
!= (inequality – always return TRUE for different-sized arrays)
= (assignment)
<< (for outputting the array in row and column format)
>> (for inputting the entire array contents)
6. You must implement a ChangeSize() method on your class. 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. When the array is made smaller in any dimension, existing elements will be
truncated (pruned) in that dimension.
7. The TSArray class must contain a test driver as part of the class (as you did with the MyRect class).
For this particular assignment, there is no program. The test driver is the only main that you created,
and must adequately demonstrate that the class works. I will be running my own test driver against
your class to prove it works.
8. As before, you must use Doxygen to document your class.
Format: Provide the information as follows:
1. Upload the program via the web.
2. You must zip up all files (TSArray.h, TSArray.cpp and the html folder) into a single archive before
uploading to the web. Please append _hw4 to the name somewhere.
3. Please include your full name as part of the file header in the program files.
pf2

Partial preview of the text

Download Homework 4 - Object Oriented Programming in C++ | CIS 554 and more Assignments Computer Science in PDF only on Docsity!

CIS 554 Homework 4

Homework Objective : Provide students with an opportunity to understand and become comfortable with creating more complex classes, operator overloading, data structures, and memory allocation and management. Also demonstrates use of friend functions and friend classes with tightly coupled objects. Description: Tri-Scripted Array Class

  1. Create a class TSArray (Tri-Scripted Array) that has similar features to the single-dimensioned myIntArray class I went over. You MUST name your class TSArray. Otherwise, you will not be able to use the IntNode class correctly.
  2. TSArray 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 array is created, the input parameters (i.e. constructor parameters) are only used to determine the maximum size of the array, but no memory is actually allocated for any array elements when a TSArray object is created.
  3. The TSArray class will be composed of a singly linked list class as its underlying storage implementation of the sparse list. At construction time, the TSArray class should be able to create an array of any number of elements in each of the dimensions (i.e. number of rows, columns and depth). You will use the NodeSLList class I have provided on the web as your linked list
  4. The TSArray class should supply operator() to perform tri-scripting operations. For example, in a MxNxO TSArray called myArray , the user could write myArray(1,2,3) to access the element at row 1, column 2, depth 3. Note that myArray(0,0,0) does not exist, and should return 0. The first element will be myArray(1,1,1). Remember that operator() can receive any number of arguments. (see class String in Figure 11.9 thru Figure 8.11 for an example of operator() ).
  5. The class should also provide the following operators. You must provide rational behavior for each operator. The assignment operator will dynamically re-size the lvalue array to the size of the rvalue array, and assign all the values of the lvalue elements to the rvalue values.  = = (equality – always return FALSE for different-sized arrays)  != (inequality – always return TRUE for different-sized arrays)  = (assignment)  << (for outputting the array in row and column format)  >> (for inputting the entire array contents)
  6. You must implement a ChangeSize() method on your class. 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. When the array is made smaller in any dimension, existing elements will be truncated (pruned) in that dimension.
  7. The TSArray class must contain a test driver as part of the class (as you did with the MyRect class). For this particular assignment, there is no program. The test driver is the only main that you created, and must adequately demonstrate that the class works. I will be running my own test driver against your class to prove it works.
  8. As before, you must use Doxygen to document your class. Format: Provide the information as follows:
  9. Upload the program via the web.
  10. You must zip up all files (TSArray.h, TSArray.cpp and the html folder) into a single archive before uploading to the web. Please append _hw4 to the name somewhere.
  11. Please include your full name as part of the file header in the program files.

TSArray

NodeSLList

IntNode