/* * *A test program for our linkedlist.c program * * * Jared Baszler and Joe Pipkins */ #include #include "linkedlist.c" void instructions(); /*Declaration of variables*/ int operations; char str[128]; char filename[128]; struct Node *list; /*Function that gives the instructions to the user*/ void instructions() { printf("\nYou chioce of operations are:\n"); printf("1.Make a new list.\n"); printf("2.Read a list from a file.\n"); printf("3.Add to the front of the list.\n"); printf("4.Add to the end of the list.\n"); printf("5.Delete the current node and element from your list.\n"); printf("6.Print your list.\n"); printf("7.Write your list to a file.\n"); printf("8.Quit program.\n"); printf("\nEnter operation that you wish to do: "); }/*instructions*/ /* Main function of our tester. */ int main() { /*prints our instructions and asks for operation#*/ instructions(); scanf("%d", &operations); while (operations !=8) { switch(operations) { /*If operation is '1' then follow this sequence *of steps to create a new list */ case 1: /*Ask for first element of new list and create a new list*/ printf("\nEnter the first element of your list: "); scanf("%s", str); list=newList(str); printf("You have created a new list containing: \n"); print(list); printf("\n"); break; /*If operation is '2' then follow this sequence *of steps read from a file */ case 2: /*Ask for the file name and read from that file.*/ printf("\n\nEnter the filename that you wish to read from: \n"); scanf("%s", filename); readFromFile(filename); printf("\nWARNING! We can not currently read from a file!\n"); /*readFromFile(fileName);*/ break; /*If operation is '3' then follow this sequence *of steps to add to the front of the list */ case 3: /*Ask for the element to be added to the front of the list*/ scanf("%", str); /*Add the element to the front of the list*/ addToFront(list, str); break; /*If operation is '4' then follow this sequence *of steps to add to the end of the list */ case 4: /*Ask for the element to be added to the end of the list*/ scanf("%", str); /*Add the element to the end of the list*/ addToEnd(list, str); break; /*If operation is '5' then follow this sequence *of steps to delete a node and it's contents */ case 5: /*delete the current node and element from the list*/ delete(list); break; /*If operation is '6' then follow this sequence *of steps to print your list */ case 6: list=newList(str); printf("\nYour list is comprised of the following elements:\n"); /*print the newly made list*/ print(list); printf("\n\n"); break; /*If operation is '7' then follow this sequence *of steps to write to a file */ case 7: /*Ask for the file to write the list to*/ printf("Enter the file name that you wish to write to: \n"); scanf("%s", filename); printf("Warning! We can not write to a file yet!\n"); break; /*If operation is '8' then follow this sequence *of steps to quit the program */ case 8: /*Quit the program*/ printf("The program is now shutting down.\n"); exit(0); break; /*This is the default case. If an invalid operator is selected then *say so and then reprint the instructions */ default: printf("\nThe operation that you have selected was invalid. \n"); printf("Please select a valid operation.\n"); instructions; }/*switch*/ instructions(); scanf("%d", &operations); }/*while*/ }/* main */