Uploading last bits

+- StateUtilities.c
+- PA02_Main.c
+- PA02_Main
+- outDebug
This commit is contained in:
Charles Descamps 2023-09-10 22:12:17 -07:00
parent 9eed1d98d3
commit ae256e5ac2
4 changed files with 30 additions and 17 deletions

View file

@ -104,9 +104,14 @@ Dependencies: as needed
*/
void copyArray( StateDataType *dest, const StateDataType *src, int srcSize )
{
int currentSize;
// 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.
for(currentSize = 0; currentSize < srcSize; currentSize++)
{
// copy each element from the array to the new array.
// uses deepCopy to do this.
deepCopy(dest, *src);
}
// no return, void
}
@ -226,7 +231,7 @@ void displayData( const StateDataType *array, int size, const char *subTitle )
printCharacter(PIPE);
// print new line
printEndline();
for(countStates = 0; countStates <= size; countStates++)
for(countStates = 0; countStates < size - 1; countStates++)
{
// use the constants to format the table
// print PIPE character
@ -244,7 +249,7 @@ void displayData( const StateDataType *array, int size, const char *subTitle )
// print PIPE character
printCharacter(PIPE);
// print growth justified right, need a % sign too. (requires some math trickery to make work)
printDoubleJustified(array[countStates].growth, PRECISION_2, GROWTH_BLOCK_SIZE - 2, "RIGHT");
printDoubleJustified(array[countStates].growth * 100.00, PRECISION_2, GROWTH_BLOCK_SIZE - 2, "RIGHT");
printCharacter('%');
printCharacter(SPACE);
// print PIPE character
@ -281,9 +286,6 @@ void displayData( const StateDataType *array, int size, const char *subTitle )
printCharacters(MAJORITY_BLOCK_SIZE, DASH);
// print PIPE character
printCharacter(PIPE);
/* testing
*/
printf("Iteration: %d", countStates);
// print endline
printEndline();
}
@ -315,10 +317,19 @@ Dependencies: as needed
bool findStateByName( StateDataType *foundElement,
const StateDataType *array, int size, const StateDataType searchValue )
{
int nameCount;
// iterate through array
// check to see if the state name is found (use searchValue)
// copy the element out of the array, put in foundElement
// return true
for(nameCount = 0; nameCount < size; nameCount++)
{
// check to see if the state name is found (use searchValue)
if(strcmp(array[nameCount].name, searchValue.name) == 0)
{
// copy the element out of the array, put in foundElement
deepCopy(foundElement, array[nameCount]);
// return true
return true;
}
}
// otherwise, return false
return false;
}
@ -342,13 +353,15 @@ Dependencies: as needed
bool removeStateByName( StateDataType *removedElement,
StateDataType *array, int *size, const StateDataType searchVal )
{
bool stateNameFound;
stateNameFound = findStateByName();
// iterate through array
// use the findStateByName to search
// remove the element by copying the next element into last slot until end
// reduce the size by one
// return true
// otherwise, return false
return NULL;
return false;
}
/*
@ -529,7 +542,7 @@ int uploadStateData( StateDataType *StateDataArray,
readStringToDelimiterFromFile(COMMA, currentString);
// find a way to cast string to double, using sscanf.
sscanf(currentString, "%lf", &growthUpload);
stateUpload->growth = growthUpload * 100;
stateUpload->growth = growthUpload;
// read in the majority, store
readStringToDelimiterFromFile(COMMA, currentString);
// get the first character of currentString