Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MAIN.C HERE IT IS!!!!!!!!!! #include #include #include #include note.h typedef enum { ADD_NOTE, ADD_ITEM, PRINT_NOTE, NOTE_SIZE, STATS, ADD_NOTE_ORDERED, ADD_ITEM_ORDERED, REMOVE_NOTE, REMOVE_ITEM, HELP, QUIT, INVALID }

image text in transcribed

image text in transcribed

MAIN.C HERE IT IS!!!!!!!!!!

#include  #include  #include  #include "note.h" typedef enum { ADD_NOTE, ADD_ITEM, PRINT_NOTE, NOTE_SIZE, STATS, ADD_NOTE_ORDERED, ADD_ITEM_ORDERED, REMOVE_NOTE, REMOVE_ITEM, HELP, QUIT, INVALID } Option; Option getAction(void); void printOptions(void); void optionDetails(void); char *getString(char *); int main( int argc, char* argv[ ] ) { Note *myNotes = NULL; char *nameNote, *nameItem; Option opt; printf(" Project 6 - note management system "); opt = getAction(); while (opt != QUIT) { switch (opt) { case ADD_NOTE: printf("Adding a new note "); nameNote = getString("Enter the name of the new note"); printf(" Adding the note '%s' (add-at-front) ", nameNote); myNotes = addNote(myNotes, nameNote); break; case ADD_ITEM: printf("Add an item to an existing note "); nameNote = getString("Enter the name of the note"); nameItem = getString("Enter the name of the item to add"); printf(" Adding the item '%s' to the note '%s' (add-at-end) ", nameItem, nameNote); addItem(myNotes, nameNote, nameItem); break; case PRINT_NOTE: printf("Print a note "); nameNote = getString("Enter the name of the note"); printf(" Printing the items in the note '%s' ", nameNote); printNote(myNotes, nameNote); break; case NOTE_SIZE: printf("Finding the size of a note "); nameNote = getString("Enter the name of the note"); printf(" The note '%s' contains %d items ", nameNote, noteSize(myNotes, nameNote) ); break; case STATS: printf("Print all information on all your notes "); printAll(myNotes); break; case ADD_NOTE_ORDERED: printf("Adding a new note (ordered) "); nameNote = getString("Enter the name of the new note"); printf(" Adding note '%s' (in alphabetical order) ", nameNote); myNotes = addNoteOrdered(myNotes, nameNote); break; case ADD_ITEM_ORDERED: printf("Add an item to a note (ordered) "); nameNote = getString("Enter the name of the note"); nameItem = getString("Enter the name of the item to add"); printf(" Adding the item '%s' to the note '%s' (alphabetical) ", nameItem, nameNote); addItemOrdered(myNotes, nameNote, nameItem); break; case REMOVE_ITEM: printf("Removing an item from a note "); nameNote = getString("Enter the name of the note"); nameItem = getString("Enter the name of the item to remove"); printf(" Removing item '%s' from the note %s ", nameItem, nameNote); removeItem(myNotes, nameNote, nameItem); break; case REMOVE_NOTE: printf("Removing a note "); nameNote = getString("Enter the name of the note to remove"); printf(" Removing the note %s ", nameNote); myNotes = removeNote(myNotes, nameNote); break; case HELP: optionDetails(); break; default: break; } opt = getAction(); } return 0; } Option getAction(void) { // print the list of options printOptions(); Option answer = INVALID; while (answer == INVALID) { // read the user command char input[32]; fgets(input, 31, stdin); input[strlen(input)-1] = '\0'; // update answer if (strcmp(input, "quit") == 0) answer = QUIT; else if (strcmp(input, "addnote") == 0) answer = ADD_NOTE; else if (strcmp(input, "additem") == 0) answer = ADD_ITEM; else if (strcmp(input, "print") == 0) answer = PRINT_NOTE; else if (strcmp(input, "size") == 0) answer = NOTE_SIZE; else if (strcmp(input, "stats") == 0) answer = STATS; else if (strcmp(input, "noteorder") == 0) answer = ADD_NOTE_ORDERED; else if (strcmp(input, "itemorder") == 0) answer = ADD_ITEM_ORDERED; else if (strcmp(input, "dumpnote") == 0) answer = REMOVE_NOTE; else if (strcmp(input, "dumpitem") == 0) answer = REMOVE_ITEM; else if (strcmp(input, "help") == 0) answer = HELP; else { if (strlen(input)>0) { printf(" INVALID OPTION "); printOptions(); } } } return answer; } void printOptions(void) { printf(" Options: addnote additem print size stats noteorder itemorder dumpnote dumpitem help quit "); printf("Select an option: "); } void optionDetails(void) { printf(" The Options are: "); printf("\taddnote Create a new note (add-at-front) "); printf("\tadditem Add an item to an existing note (add-at-end) "); printf("\tprint Print the item in a note "); printf("\tsize Return the size of a note (count of items in the note) "); printf("\tstats Print statistics on all your notes "); printf("\tnoteorder Create a new note (in alphabetical order) "); printf("\titemorder Add an item to an existing note (in alphabetical order) "); printf("\tdumpnote Remove a note "); printf("\tdumpitem Remove an item from a note "); printf("\thelp Display this detailed menu "); printf("\tquit Exit the program "); } char *getString(char *str) { char input[1024]; printf("%s : ", str); fgets(input, 1023, stdin); input[strlen(input)-1] = '\0'; // get rid of character char *answer = (char *) malloc (strlen(input) + 1); strcpy(answer, input); return answer; } 

NOTE.H HERE IT IS!!!!!!!!!!

image text in transcribed

NOTE.C THIS IS WHAT I NEED HELP WITH!!!!! EVERYTHING RUNS TOGETHER SO PLEASE DON'T POST MAIN.C OR NOTE.H! THANKS!

#include "note.h" ///////////////////////////////////////////////////////////////////////////////////////////// // add a new note to your list of note Note* addNote(Note *myNotes, char *noteName) { /* 1. Make sure a note by that name does not exist 2. Add a new note with that name (add-at-front) */ return myNotes; } ///////////////////////////////////////////////////////////////////////////////////////////// // adds a new item to the specified note void addItem(Note *myNotes, char *noteName, char *itemName) { /* 1. Make sure a note by that name exists (so you can add an item to it) 2. Make sure the item does not already exist in the note 2. Add the item to the end of the note (add-at-end) */ return; } ///////////////////////////////////////////////////////////////////////////////////////////// // prints all the items in a given note void printNote(Note *myNotes, char *noteName) { /* 1. Make sure a note with that name exists 2. Print the name of the note, then 3. print each item in the note on separate line */ return; } ///////////////////////////////////////////////////////////////////////////////////////////// // returns the size of a given note int noteSize(Note *myNotes, char *noteName) { /* 1. Make sure a note with that name exists 2. Count the number of items in the note, return that count */ return -1; } ///////////////////////////////////////////////////////////////////////////////////////////// // prints statistics on all your notes void printAll(Note *myNotes) { /* For each note a. Print the name of the note b. Print the number of items in the note c. Print all the items in that note Note: this code can call other functions as needed */ return; } ///////////////////////////////////////////////////////////////////////////////////////////// // add a new note (in alphabetical order) Note* addNoteOrdered(Note *myNotes, char *noteName) { /* 1. Make sure a note by that name does not exist 2. Add a new note with that name (add-in-order) */ return myNotes; } ///////////////////////////////////////////////////////////////////////////////////////////// // adds a new item to the specified note (in alphabetical order) void addItemOrdered(Note *myNotes, char *noteName, char *itemName) { /* 1. Make sure a note by that name exists (so you can add an item to it) 2. Make sure the the item does not already exist in the note 3. Add the new item to the note (add-in-order) */ return; } ///////////////////////////////////////////////////////////////////////////////////////////// // remove an item from a note void removeItem(Note *myNotes, char *noteName, char *itemName) { /* 1. Make sure a note with that name exists 2. Make sure the item exists in that note 3. Remove the item from the list of items in that note */ return; } ///////////////////////////////////////////////////////////////////////////////////////////// // remove a note Note *removeNote(Note *myNotes, char *noteName) { /* 1. Make sure a note with that name exists 2. Remove that note */ return myNotes; } ///////////////////////////////////////////////////////////////////////////////////////////// 
Project Overview: The world is full of lists. You realized this as your parents were marveling at how wonderful their new "notes" application on their smartphone was. They love the idea of being able to maintain grocery lists (or Walmart lists or Target lists, simply adding and removing items as they need. You realize that this "notes app" is nothing more than a set of linked lists. For this project, we will write our own version of "notes" that uses the two data structures shown below: typedef struct note typedef struct item char name char name Item *itemList; struct item next struct note next I tem. The basic idea is that you have a list of notes. Each note has a name and a list of items in that note. Each item in the note is an English description of the item and a pointer to the next item in that note. The example below shows two notes, the first with three items and the second with two items. In the example below, you have one linked list of Notes (that contains two notes a Publix note and a Walmart note). This linked list is shown in red. Each "note contains a linked list of items, so you have two linked lists of Items (one for the Publix note and one for the Walmart note). These two linked lists are shown in blue and green List Head of Note Publix Walmart Head of Item List List Head of Item Next not NULL Gallon of Milk 3-t Loaf of bread Toothpaste Toothbrush apples NULL Next Item NUL Next Item In building this project, we establish the user interface (what the user actually does to create and modify and print and remove notes and then define a set of back-end functions that actually manage the linked lists. Given this, we separate our program into three files as shown below: contains the user interface code. This prompts the user for an action and performs that action. main. C note h -contains definitions of our structures and function prototypes for all the linked list functions implementation of the functions listed in note.h that manipulate the linked lists. These note .c nctions are called by the main.c routine as needed to complete the various operations For this project, we will give you a working version of main.c and note.h and a skeleton empty note.c file. You only have to complete the nine functions in note.c that manipulate linked lists What You Need To Do Create a directory project6 on your machine. In that directory, you will have three files, main.c and note h and note c. The files main.c and note.h have already been written, you must complete note.c o The file main.c is the user interface (driver routine. It contains the main program that calls the various functions used to create and maintain notes o The file note h contains declarations for the two structures used in the program, as well as function signatures for all the functions used by the driver routine o The file note c contains the actual code used to implement each of the functions

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MFDBS 91 3rd Symposium On Mathematical Fundamentals Of Database And Knowledge Base Systems Rostock Germany May 6 9 1991

Authors: Bernhard Thalheim ,Janos Demetrovics ,Hans-Detlef Gerhardt

1991st Edition

3540540091, 978-3540540090

More Books

Students also viewed these Databases questions

Question

Does it exceed two pages in length?

Answered: 1 week ago

Question

Does it avoid typos and grammatical errors?

Answered: 1 week ago