Initialized STUB Functions, Refined Make
++ PA02 STUB functions/StateUtilities.c -- Makefile_Win (No longer required since refined for Windows/UNIX)
This commit is contained in:
parent
ee473c78b1
commit
91b6fc42d5
3 changed files with 311 additions and 40 deletions
|
|
@ -1,17 +1,17 @@
|
|||
CC = gcc -Wall
|
||||
SOURCES = PA01_Main.c EncryptionUtility.c Console_IO_Utility.c File_Input_Utility.c File_Output_Utility.c
|
||||
OBJECTS = PA01_Main.o EncryptionUtility.o Console_IO_Utility.o File_Input_Utility.o File_Output_Utility.o
|
||||
SOURCES = PA02_Main.c StateUtilities.c Console_IO_Utility.c File_Input_Utility.c File_Output_Utility.c
|
||||
OBJECTS = PA02_Main.o StateUtilities.o Console_IO_Utility.o File_Input_Utility.o File_Output_Utility.o
|
||||
|
||||
all: PA01_Main
|
||||
all: PA02_Main
|
||||
|
||||
PA01_Main: $(OBJECTS)
|
||||
$(CC) $(OBJECTS) -o PA01_Main
|
||||
PA02_Main: $(OBJECTS)
|
||||
$(CC) $(OBJECTS) -o PA02_Main
|
||||
|
||||
PA01_Main.o: PA01_Main.c
|
||||
$(CC) -c PA01_Main.c -o PA01_Main.o
|
||||
PA02_Main.o: PA02_Main.c
|
||||
$(CC) -c PA02_Main.c -o PA02_Main.o
|
||||
|
||||
EncryptionUtility.o: EncryptionUtility.c
|
||||
$(CC) -c EncryptionUtility.c -o EncryptionUtility.o
|
||||
StateUtilities.o: StateUtilities.c
|
||||
$(CC) -c StateUtilities.c -o StateUtilities.o
|
||||
|
||||
Console_IO_Utility.o: Console_IO_Utility.c
|
||||
$(CC) -c Console_IO_Utility.c -o Console_IO_Utility.o
|
||||
|
|
@ -23,10 +23,13 @@ File_Output_Utility.o: File_Output_Utility.c
|
|||
$(CC) -c File_Output_Utility.c -o File_Output_Utility.o
|
||||
|
||||
clean:
|
||||
rm -f $(OBJECTS) PA01_Main PA01_Main.out
|
||||
rm -f $(OBJECTS) PA02_Main PA02_Main.out
|
||||
|
||||
clean_objects:
|
||||
rm -f $(OBJECTS)
|
||||
|
||||
run:
|
||||
./PA01_Main
|
||||
./PA02_Main
|
||||
|
||||
run_win:
|
||||
PA02_Main
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
CC = gcc -Wall
|
||||
SOURCES = PA01_Main.c EncryptionUtility.c Console_IO_Utility.c File_Input_Utility.c File_Output_Utility.c
|
||||
OBJECTS = PA01_Main.o EncryptionUtility.o Console_IO_Utility.o File_Input_Utility.o File_Output_Utility.o
|
||||
|
||||
all: PA01_Main
|
||||
|
||||
PA01_Main: $(OBJECTS)
|
||||
$(CC) $(OBJECTS) -o PA01_Main.exe
|
||||
|
||||
PA01_Main.o: PA01_Main.c
|
||||
$(CC) -c PA01_Main.c -o PA01_Main.o
|
||||
|
||||
EncryptionUtility.o: EncryptionUtility.c
|
||||
$(CC) -c EncryptionUtility.c -o EncryptionUtility.o
|
||||
|
||||
Console_IO_Utility.o: Console_IO_Utility.c
|
||||
$(CC) -c Console_IO_Utility.c -o Console_IO_Utility.o
|
||||
|
||||
File_Input_Utility.o: File_Input_Utility.c
|
||||
$(CC) -c File_Input_Utility.c -o File_Input_Utility.o
|
||||
|
||||
File_Output_Utility.o: File_Output_Utility.c
|
||||
$(CC) -c File_Output_Utility.c -o File_Output_Utility.o
|
||||
|
||||
clean:
|
||||
del /F $(OBJECTS) PA01_Main PA01_Main.out
|
||||
|
||||
clean_objects:
|
||||
del /F $(OBJECTS)
|
||||
|
|
@ -0,0 +1,297 @@
|
|||
#include "StateUtilities.h"
|
||||
|
||||
// local constants
|
||||
const int NAME_BLOCK_SIZE = 16;
|
||||
const int POPULATION_BLOCK_SIZE = 12;
|
||||
const int GROWTH_BLOCK_SIZE = 10;
|
||||
|
||||
// functions
|
||||
|
||||
/*
|
||||
Name: addElementFromData
|
||||
Process: adds all individual data values to StateDataType array
|
||||
if capacity has not been exceeded,
|
||||
returns true upon success, false otherwise
|
||||
Function input/parameters: data array (StateDataType *),
|
||||
size (int), capacity (int),
|
||||
state name (const char *),
|
||||
state population (int),
|
||||
state growth (double),
|
||||
state political majority (char)
|
||||
Function output/parameters: updated data array (StateDataType *),
|
||||
updated size (int *)
|
||||
Function output/returned: Boolean result of operation as specified
|
||||
Device input/---: none
|
||||
Device output/---: none
|
||||
Dependencies: as needed, including strcpy
|
||||
*/
|
||||
bool addElementFromData( StateDataType *stateArr, int *size, int capacity,
|
||||
const char *stateName, int statePop,
|
||||
double stateGrowth, char politicalMajority )
|
||||
{
|
||||
//
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: addElementFromElement
|
||||
Process: adds data from element to StateDataType array,
|
||||
uses supporting function
|
||||
Function input/parameters: data array (StateDataType *),
|
||||
size and capacity (int),
|
||||
source element (const StateDataType)
|
||||
Function output/parameters: updated data array (StateDataType *),
|
||||
updated size (int *)
|
||||
Function output/returned: Boolean result of operation as specified
|
||||
Device input/---: none
|
||||
Device output/---: none
|
||||
Dependencies: addElementFromData - function uses one code statement
|
||||
*/
|
||||
bool addElementFromElement( StateDataType *stateArr, int *size, int capacity,
|
||||
const StateDataType state )
|
||||
{
|
||||
//
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: clearStateArray
|
||||
Process: deallocates dynamically allocated array from memory
|
||||
Function input/parameters: data array (StateDataType *)
|
||||
Function output/parameters: none
|
||||
Function output/returned: NULL
|
||||
Device input/---: none
|
||||
Device output/---: none
|
||||
Dependencies: as needed, including free
|
||||
*/
|
||||
StateDataType *clearStateArray( StateDataType *array )
|
||||
{
|
||||
//
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: copyArray
|
||||
Process: copies state data elements from one array to another
|
||||
Function input/parameters: source array (const StateDataType *), size (int)
|
||||
Function output/parameters: pointer to destination array (StateDataType *)
|
||||
Function output/returned: none
|
||||
Device input/---: none
|
||||
Device output/---: none
|
||||
Dependencies: as needed
|
||||
*/
|
||||
void copyArray( StateDataType *dest, const StateDataType *src, int srcSize )
|
||||
{
|
||||
// no return, void
|
||||
}
|
||||
|
||||
/*
|
||||
Name: createStateArray
|
||||
Process: dynamically allocates array memory
|
||||
Function input/parameters: initial capacity (int)
|
||||
Function output/parameters: none
|
||||
Function output/returned: pointer to newly created array (StateDataType *)
|
||||
Device input/---: none
|
||||
Device output/---: none
|
||||
Dependencies: as needed, including function malloc and keyword sizeof
|
||||
*/
|
||||
StateDataType *createStateArray( int initialCapacity )
|
||||
{
|
||||
//
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: deepCopy
|
||||
Process: copies all individual values from StateDataType source
|
||||
to StateDataType destination
|
||||
Function input/parameters: source element (const StateDataType)
|
||||
Function output/parameters: pointer to destination value (StateDataType *)
|
||||
Function output/returned: none
|
||||
Device input/---: none
|
||||
Device output/---: none
|
||||
Dependencies: as needed, including strcpy
|
||||
*/
|
||||
void deepCopy( StateDataType *dest, const StateDataType src )
|
||||
{
|
||||
// no return, void
|
||||
}
|
||||
|
||||
/*
|
||||
Name: displayData
|
||||
Process: displays element data in array as table if array is not empty,
|
||||
otherwise displays "Data not found - Display aborted",
|
||||
allows for subtitle to be added to "Display Data - "
|
||||
Function input/parameters: state data array (const StateDataType *),
|
||||
size (int), subtitle (const char *)
|
||||
Function output/parameters: none
|
||||
Function output/returned: none
|
||||
Device input/---: none
|
||||
Device output/monitor: data displayed as specified
|
||||
Dependencies: as needed
|
||||
*/
|
||||
void displayData( const StateDataType *array, int size, const char *subTitle )
|
||||
{
|
||||
// no return, void
|
||||
}
|
||||
|
||||
/*
|
||||
Name: findStateByName
|
||||
Process: finds element value in array by state name if it exists in the array,
|
||||
saves data in return parameter and returns true,
|
||||
otherwise sets data in return parameter to empty and returns false
|
||||
Function input/parameters: state data array (const StateDataType *),
|
||||
size (int), search value (const StateDataType)
|
||||
Function output/parameters: value if found as return parameter,
|
||||
otherwise, return parameter set to empty
|
||||
(StateDataType *)
|
||||
Function output/returned: Boolean result of operation
|
||||
Device input/---: none
|
||||
Device output/---: none
|
||||
Dependencies: as needed
|
||||
*/
|
||||
bool findStateByName( StateDataType *foundElement,
|
||||
const StateDataType *array, int size, const StateDataType searchValue )
|
||||
{
|
||||
//
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: removeStateByName
|
||||
Process: searches for element, if found, sets data into return parameter,
|
||||
shifts all remaining data down, and returns true,
|
||||
otherwise sets data in return parameter to empty and returns false
|
||||
Function input/parameters: state data array (StateDataType *),
|
||||
size (int), search value (const StateDataType)
|
||||
Function output/parameters: updated state data array (StateDataType *),
|
||||
value if found and removed,
|
||||
otherwise, value set to empty (StateDataType *),
|
||||
updated size (int *)
|
||||
Function output/returned: Boolean result of operation as specified
|
||||
Device input/---: none
|
||||
Device output/---: none
|
||||
Dependencies: as needed
|
||||
*/
|
||||
bool removeStateByName( StateDataType *removedElement,
|
||||
StateDataType *array, int *size, const StateDataType searchVal )
|
||||
{
|
||||
//
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: runBubbleSortByName
|
||||
Process: sorts state data by name using bubble sort algorithm
|
||||
Function input/parameters: state data array (StateDataType *), size (int)
|
||||
Function output/parameters: updated state data array (StateDataType *)
|
||||
Function output/returned: none
|
||||
Device input/---: none
|
||||
Device output/---: none
|
||||
Dependencies: as needed
|
||||
*/
|
||||
void runBubbleSortByName( StateDataType *array, int size )
|
||||
{
|
||||
// no return, void
|
||||
}
|
||||
|
||||
/*
|
||||
Name: runInsertionSortByPopulation
|
||||
Process: sorts state data by population using insertion sort algorithm
|
||||
Function input/parameters: state data array (StateDataType *), size (int)
|
||||
Function output/parameters: updated state data array (StateDataType *)
|
||||
Function output/returned: none
|
||||
Device input/---: none
|
||||
Device output/---: none
|
||||
Dependencies: as needed, swap may not be used
|
||||
*/
|
||||
void runInsertionSortByPopulation( StateDataType *array, int size )
|
||||
{
|
||||
// no return, void
|
||||
}
|
||||
|
||||
/*
|
||||
Name: runSelectionSortByGrowth
|
||||
Process: sorts state data by growth using selection sort algorithm
|
||||
Function input/parameters: state data array (StateDataType *), size (int)
|
||||
Function output/parameters: updated state data array (StateDataType *)
|
||||
Function output/returned: none
|
||||
Device input/---: none
|
||||
Device output/---: none
|
||||
Dependencies: as needed
|
||||
*/
|
||||
void runSelectionSortByGrowth( StateDataType *array, int size )
|
||||
{
|
||||
// no return, void
|
||||
}
|
||||
|
||||
/*
|
||||
Name: setEmptyElementData
|
||||
Process: sets state data type to empty or default values,
|
||||
name to empty string, population and growth to zero,
|
||||
and majority to 'x'
|
||||
Function input/parameters: none
|
||||
Function output/parameters: state data value (StateDataType *)
|
||||
Function output/returned: none
|
||||
Device input/---: none
|
||||
Device output/---: none
|
||||
Dependencies: none
|
||||
*/
|
||||
void setEmptyElementData( StateDataType *element )
|
||||
{
|
||||
// no return, void
|
||||
}
|
||||
|
||||
/*
|
||||
Name: showTitle
|
||||
Process: displays program title with thick underline,
|
||||
"Data Management with N-Squared Sorting"
|
||||
Function input/parameters: none
|
||||
Function output/parameters: none
|
||||
Function output/returned: none
|
||||
Device input/---: none
|
||||
Device output/monitor: displays title as specified
|
||||
Dependencies: as needed
|
||||
*/
|
||||
void showTitle()
|
||||
{
|
||||
// no return, void
|
||||
}
|
||||
|
||||
/*
|
||||
Name: swapElements
|
||||
Process: swaps state data elements within an array
|
||||
Function input/parameters: given array (StateDataType *),
|
||||
left and right indices to be swapped (int)
|
||||
Function output/parameters: updated array with swapped values (StateDataType *)
|
||||
Function output/returned: none
|
||||
Device input/---: none
|
||||
Device output/---: none
|
||||
Dependencies: as needed
|
||||
*/
|
||||
void swapElements( StateDataType *array, int leftIndex, int rightIndex )
|
||||
{
|
||||
// no return, void
|
||||
}
|
||||
|
||||
/*
|
||||
Name: uploadStateData
|
||||
Process: uploads data from given file to state data array,
|
||||
ignores first (title) line in .csv file,
|
||||
then captures comma-delimited state name, population, growth,
|
||||
and political majority data on each row,
|
||||
returns number of items found;
|
||||
stops uploading process if array is full
|
||||
Function input/parameters: capacity (int) and file name (const char *)
|
||||
Function output/parameters: updated array with uploaded values (StateDataType *)
|
||||
Function output/returned: number of items uploaded (int)
|
||||
Device input/HD: data uploaded from text file as specified
|
||||
Device output/---: none
|
||||
Dependencies: as needed
|
||||
*/
|
||||
int uploadStateData( StateDataType *StateDataArray,
|
||||
int capacity, const char *fileName )
|
||||
{
|
||||
//
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue