diff --git a/PA02-0913/StateUtilities.c b/PA02-0913/StateUtilities.c index 82bb305..0234d21 100644 --- a/PA02-0913/StateUtilities.c +++ b/PA02-0913/StateUtilities.c @@ -4,6 +4,9 @@ const int NAME_BLOCK_SIZE = 16; const int POPULATION_BLOCK_SIZE = 12; const int GROWTH_BLOCK_SIZE = 10; +// missing constants from assignment file +const int ITEM_BLOCK_SIZE = 6; +const int MAJORITY_BLOCK_SIZE = 10; // functions @@ -29,8 +32,15 @@ bool addElementFromData( StateDataType *stateArr, int *size, int capacity, const char *stateName, int statePop, double stateGrowth, char politicalMajority ) { - // - return NULL; + // check to see if the size will go over the capacity + // put in the data to the array + // array[*size] = parameter + // string is a little different. + // use strcpy(array[*size].name, stateName) + // increment size (*size = *size + 1) + // return true + // otherwise, return false. + return false; } /* @@ -50,8 +60,8 @@ Dependencies: addElementFromData - function uses one code statement bool addElementFromElement( StateDataType *stateArr, int *size, int capacity, const StateDataType state ) { - // - return NULL; + return addElementFromData(stateArr, size, capacity, state.name, + state.population, state.growth, state.majority); } /* @@ -66,7 +76,7 @@ Dependencies: as needed, including free */ StateDataType *clearStateArray( StateDataType *array ) { - // + // use free to deallocate the array return NULL; } @@ -82,10 +92,13 @@ Dependencies: as needed */ void copyArray( StateDataType *dest, const StateDataType *src, int srcSize ) { + // use a for loop to iterate through source array (start at zero, go to srcSize) + // copy each element from the array to the new array. + // uses deepCopy to do this. // no return, void } -/* +/* COMPLETE Name: createStateArray Process: dynamically allocates array memory Function input/parameters: initial capacity (int) @@ -97,7 +110,10 @@ Dependencies: as needed, including function malloc and keyword sizeof */ StateDataType *createStateArray( int initialCapacity ) { - // + // define variables (integer, StateDataType) + // use malloc to dynamically allocate the array, + // use the initialCapacity as the size to multiply by. + // return the pointer to the array. return NULL; } @@ -114,6 +130,9 @@ Dependencies: as needed, including strcpy */ void deepCopy( StateDataType *dest, const StateDataType src ) { + // *dest.population = src.population (for each piece) + // strcpy for the string + // strcpy(*dest.name, src.name) // no return, void } @@ -193,6 +212,7 @@ Dependencies: as needed void runBubbleSortByName( StateDataType *array, int size ) { // no return, void + // bubble sort the data by name of state } /* @@ -271,6 +291,11 @@ Dependencies: as needed */ void swapElements( StateDataType *array, int leftIndex, int rightIndex ) { + // create StateDataType temp to store swapped element + // use deepCopy to copy out swapped element + // use deepCopy to move the other element, + // use deepCopy to copy the temp element to the other element + // updated the array // no return, void } diff --git a/PA02-0913/build/Debug/outDebug b/PA02-0913/build/Debug/outDebug new file mode 100755 index 0000000..ec674b2 Binary files /dev/null and b/PA02-0913/build/Debug/outDebug differ