CS250 Unit 08 Project: Smart Fixed-Length Array

Table of Contents


1. Introduction

About
For this project we will be implementing our first data structure, a “smart” fixed-length array. This first guide will step you through the entire process, though as we tackle more data structures in the course, less hand-holding will be done.
Goals
  • Implement a basic data structure
  • Utilize our data structure in a simple program
Starter code
https://gitlab.com/moosadee/courses/-/tree/main/wip_projects/starter_code/c4_u08_SmartFixedArray?ref_type=heads
Doxygen documentation
doxygen/c4_u08_SmartFixedArray/classDataStructure_1_1SmartFixedArray.html

2. Getting started

2.1. Creating a new branch

BEFORE getting started on the assignment, make sure to go back to the main or master branch and pull latest. This way, you will have the most up-to-date version of your repository, and you'll be starting from a shared base-point.

  1. git add . && git commit -m "backup" && git push to make sure to backup any work on your current branch.
  2. git checkout main to check out the main branch again.
  3. git pull to pull latest changes from the server.

Next, you will create a new branch to get started from:

  1. git checkout -b SmartFixedArray to create a new branch for this assignment.

2.2. Getting the starter code

Download the starter code for this assignment here:

https://gitlab.com/moosadee/courses/-/tree/main/wip_projects/starter_code/c4_u08_SmartFixedArray?ref_type=heads

Extract the contents somewhere within your course repository folder.

The following files are already part of this directory:

.
├── CuTest
│   ├── TesterBase.cpp
│   └── TesterBase.h
├── Data
│   └── products.txt
├── DataStructure
│   ├── Interfaces
│   │   └── ILinearDataStructure.h
│   └── SmartFixedArray
│       ├── SmartFixedArray.h
│       └── SmartFixedArrayTester.h
├── Doxyfile
├── Exceptions
│   ├── InvalidIndexException.h
│   ├── ItemNotFoundException.h
│   ├── NotImplementedException.h
│   ├── NullptrException.h
│   ├── StructureEmptyException.h
│   └── StructureFullException.h
├── main.cpp
├── Program
│   ├── Product.cpp
│   ├── Product.h
│   ├── Program.cpp
│   └── Program.h
├── Project_CodeBlocks
│   ├── DataStructures.cbp
│   ├── DataStructures.depend
│   └── DataStructures.layout
├── Project_Makefile
│   └── Makefile
├── Project_VisualStudio2022
│   ├── DataStructures.sln
│   ├── DataStructures.vcxproj
│   ├── DataStructures.vcxproj.filters
│   └── DataStructures.vcxproj.user
└── Utilities
    ├── Logger.cpp
    ├── Logger.h
    ├── Menu.cpp
    ├── Menu.h
    ├── StringUtil.cpp
    ├── StringUtil.h
    └── Timer.h

CuTest
The unit test framework.
Data
The path where the products.txt file is.
DataStructure/Interfaces
Contains an interface for our Linear Data Structure type.
DataStructure/SmartFixedArray
Contains the templated class declaration for the SmartFixedArray as well as the unit tests in the Tester file.
Program
(Ignore)
Utilities
Various helper functionality like string/int conversion, menu stuff, etc.

There are a lot of files, but you will be focusing on SmartFixedArray.h and Program.h and Program.cpp.

Additionally, a Visual Studio solution file is included in the Project_VisualStudio2022 folder, and a Code::Blocks project file is included in the Project_CodeBlocks folder.


3. Program overview

When you run the program it will prompt you on whether you want to run the unit tests or the program itself:

STARTUP
1. Run unit tests
2. Run program

>>

4. Opening the data structure documentation

To access the data structure's auto-generated documentation, go to this page:

doxygen/c4_u08_SmartFixedArray/classDataStructure_1_1SmartFixedArray.html

(All the documentation on the doxygen page is also written out in the data structure's comments.)

You can click on a function name to view the detailed notes about the structure and how to implement it. For future data structures assignments you will be heavily relying on the doxygen documentation rather than this type of manually created documentation page. (Hi!)


5. The important member variables!

There are three important variables that are part of the Smart Fixed-Length Array that you want to keep in mind while implementing everything:

  • T m_array[100] is the array of data.
  • const int ARRAY_SIZE is the total capacity of the array (which will be storing 100).
  • int m_itemCount is the amount of items currently stored in the array. This begins at 0.

6. Running the unit tests

There are unit tests already provided for the entire structure. Use these to validate your work. If all your unit tests pass (and the tester doesn't crash before the end ;) then you can assume that your data structure probably works correctly.

When you run the tests, the console will show a summary:

Running testset 14 out of 15: 	PushAt()
[FAIL] 0a. Check if function PushAt is implemented

Running testset 15 out of 15: 	Search()
[FAIL] 0. Check if function Search is implemented

- RESULTS ------------------------------------------------------------
- Total tests:           15
- Total tests passing:   0
- Total tests failing:   0
- 
- NOTE: CHECK "test_result_smart_fixed_array.html" in the directory --
(...)/Project_CodeBlocks
- - for full information on test results,
- including expected output vs. actual output and notes.

But to get the full summary of the tests, go to the test_result_smart_fixed_array.html file that gets generated - it will be located wherever your project file is.

c4_u08_SmartFixedArray_test-results.png

The HTML report will give you more detailed information, such as what the expected output was and what the actual output ended up being, as well as the inputs that were used. These can help you diagnose any logic errors with your code.


7. Smart Fixed-Length Array functionality

Make sure to read through the textbook for an overview of this structure's functionality. This, the video lecture, plus the doxygen documentation should help you implement it.


8. Testing the program

Use the unit tests to validate your work. All unit tests should pass.

Make sure the functionality of the Program also works.


Author: Rachel Wil Sha Singh

Created: 2023-11-02 Thu 23:08

Validate