Dana Vrajitoru
C243/A594 Data Structures

C243/A594 Homework 1

Due date: Wednesday, September 4, 2019.

Description. In this homework we will work on a small program that makes use of a class called MyArray that will implement a safe array. The goal of the class is for its objects to work like normal arrays, but where access operations are safe. Thus, a specific error message will appear when we try to access an index out of bounds.

Ex. 1. a. Inside your home directory in your Linux account (the default directory when you log on), create a folder for this class with the command
mkdir c243
if you have not done this already. Change your working directory to this folder using the command
cd c243
Repeat this steps to create a directory called hw1 or whatever you want to name it and change your working directory to it.

b. Download the following files into the folder you have created for this homework:
Makefile
MyArray.h
MyArray.cc
main.cc

If you work from a terminal in your Linux account, you can copy them directly doing something like
cp /home/dvrajito/public_html/teach/c243/p1/* ./
which will copy all the files from that directory into yours.

From a Linux system other than our labs, you can also copy them with a command like
wget http://www.cs.iusb.edu/~danav/teach/c243/p1/Makefile
and then a similar one for which of the other files.

These files are also available on Canvas, in Files, Homework 1.

c. Compile the program with the command
make
Test the program with the command
array
or if it doesn't work,
./array

Note that when you run the program, you should see an error message about illegal access to an element of the array. This is done on purpose to test the feature.

Ex. 2. a. Add some functions to the class MyArray with the given prototypes to do the following operations:


b. Modify the main function to test the three functions and at least one of the operators. For this, in the main do the following: Remove or comment out any part of the original main function that is not relevant to your program.

Upload to Canvas, under Assignments, Homework 1: all the source files (.cc and .h). If you modify the Makefile, you have to upload it too.

Note. If you worked remotely on one of our lab computers and want to submit the files from your local computer, see How To Transfer Files to get those files to your local computer. It's always a good idea to create home backup files of your homework files anyway.