Question
IN C! STARTER CODE INCLUDED! You work for a boat company. They need a program that keeps track of inventory information. Please write a multi-file
IN C! STARTER CODE INCLUDED!
You work for a boat company. They need a program that keeps track of inventory information. Please write a multi-file program to create a singly linked-list of watercraft. This will be based on structures - one for watercraft, one for accessories, and one for list, as given in a provided header file.
DIRECTIONS:
FUNCTION PROTOTYPES:
STARTER CODE: sll_list.h
#ifndef SLL_LIST_H #define SLL_LIST_H
#include
typedef struct { double bimini; // cost of the add-on double towbar; double stereo; double table; double gps; double anchor; double paddles; } accessories_t; typedef struct watercraft { char type[15]; // e.g. pontoon, sport boat, sailboat, fishing, char make[20]; char model[30]; int propulsion; // 0 = none; 1 = outBoard; 2 = inBoard; char engine[15]; // Suzuki, Yamaha, etc. int hp; // horse power char color[25]; int length; // feet double base_price; double total_price;
accessories_t extras; struct watercraft *next; } watercraft_t;
typedef struct list { watercraft_t *head; watercraft_t *tail; int size; } list_t;
int printMenu( ); list_t *newList( ); void listInit( list_t *list, FILE *inFile ); void initializeFromFile( list_t *list, FILE *inFile ); watercraft_t *new_waterCraft( FILE *inFile );
void addToFront( list_t *list ); void addToRear( list_t *list );
void printList ( list_t *list ); void printSpecs ( list_t *list );
void deleteWatercraft( list_t *list );
int typeInInventory( list_t *list, char whichOne[] ); int motorInInventory( list_t *list, int whichOne ); void printWatercraftByType( list_t *list, char whichOne[] ); void printWatercraftByMotor( list_t *list, int whichOne ); void searchByType( list_t *list ); // pontoon, fishing boat, etc. void searchByMotorType( list_t *list ); // e.g. inboard vs outboard
void printByPrice( list_t *list ); // list from lowest to highest
int isEmpty( list_t *list );
void TAV( list_t *list ); // Total Asset Value
#endif /* SLL_LIST_H */
STARTER CODE: watercraft.txt
pontoon, Crest, Carribean RS 230 SLC, 1, Suzuki, 115, Blue, 26,134595.00,135945.00,1,200,0,250,450,450,0
fishing,Key West,239 FS,1,Mercury,250,Orange,24,86430.00,87630.00,0,0,250,200,500,250,0
sport boat,Tahoe,T16,1,Yamaha,300,Yellow,22,26895.00,27745.00,0,250,0,0,350,250,0
pontoon,Bennington,24 Slx,1,Mercury,140,Brown,24,83299.00,84049.00,1,250,0,200,0,300,0
kayak,Wilderness Systems,Tarpon 120 SOT,0,None,0,Red/Orange/Yellow,12,999.00,1149.00,0,0,0,0,0,0,150
pontoon,Suntracker,Bass Buggy 16 XL,1,Suzuki,115,Silver,22,13990.00,14990.00,1,200,0,250,300,250,0
pontoon,Crest,Classic LX 220 SLC,1,Mercury,115,Green,24,45599.00,47149.00,1,250,350,200,450,300,0
fishing,Phoenix,Bass Boat 920 Elite,2,Chevrolet,300,Orange,28,46995.00,48195.00,0,0,250,300,400,250,0
kayak,Eddyline,Rio,0,None,0,Green Apple,12,1429.00,1714.00,0,0,0,0,0,0,285
canoe,Old Town,Penobscot 164 ,0,None,0,Green,16,1299.95,1524.90,0,0,0,0,0,0,224.95
canoe,Mad River,Adventure 16,0,None,0,Red,16,899.00,1058.95,0,0,0,0,0,0,159.95
pontoon,Crest,Classic LX 200 L,1,Yamaha,150,Black,22,31816.00,33016.00,1,200,0,250,450,300,0
sport boat,Chaparral,297 Surf SSX,2,Chevrolet,300,Purple,24,220079.00,221279.00,0,250,350,0,400,200,0
fishing,Avenger,AV24,1,Yamaha,115,Gray,28,89995.00,90795.00,0,0,250,0,350,200,0
sport boat,Sea Ray,SDX 270,2,Chevrolet,300,Blue,28,185113.00,186213.00,0,200,300,0,350,250,0
fishing,Nitro,Z18 Pro,1,Suzuki,140,Black,30,35585.00,36235.00,0,0,0,0,400,250,0
pontoon,Bennington,25 Qxfb,1,Mercury,115,White,22,167000.00,168250.00,1,250,0,250,450,300,0
pontoon,Bentley,200 Cruise,1,Mercury,90,Silver,20,36995.00,37795.00,1,200,350,250,0,0,0
Menu should look like this:
Your program should contain the following files: 1. mainDriver.c (contains main() function) 2. sll_list.h (header file for this singly linked-list program provided to you) 3. sll_list.c implementation file for this doubly linked-list program) 4. watercraft.txt (contains watercraft for initializing your linked-list). The watercraft can be any kind of watercraft, such as pontoon, fishing, sport boat, sailboat, kayak, canoe, even ski jets (although there are no jet skis in the test file). You can add whatever types of watercraft that you want to the test file. Make sure that no fields are skipped, though. 5. makefile (Your makefile should have at least two targets: a compile target, which renames your executable to sll; and a clean target which removes the executable and any other un-needed files, like .o files if there are any) FUNCTION PROTOTYPES Initializing The List: int printMenu(); // prints the menu to the user; returns the menu choice list t *newList(); // creates a new list; initializes size, and head & tail pointers; returns a pointer to the new list void listInit( list_t *list, FILE *inFile ); // called from initializeFromFile(); call newWatercraft () to create and 17 initialize a new watercraft from the file; then add it to the end of // the list; increments the list size for each watercraft added void initialize FromFile( list t *list, FILE *inFile ); // calls listInit() sending the input file pointer (which is the file // specified at the command-line that was opened in the main() function) watercraft t *new waterCraft( FILE *in File); // called by listInit() function // creates and initializes a new watercraft node from the input file pointer sent in // returns a pointer to the watercraft that was just created Adding Additional Watercraft: void addToFront ( list_t *list ); // creates a new watercraft from user input and then adds it to the front of the list // increments the list size void addToRear( list_t *list ); // creates a new watercraft from user input and then adds it to the rear of the list; should use the tail pointer // increments the list size Printing Entire List Of All Watercraft Or Specs Of Chosen Watercraft: void printList ( list_t *list ); // prints all the watercraft in the list void print Specs ( list_t *list ); // prints a list of he watercraf (i.e.calls printListo) and asks user to choose which one to show the specs of // the specs will include the extra items and their associated costs, if applicable Deleting A Watercraft: void deleteWatercraft( list_t *list ); // prints the list of watercraft (i.e.calls printList()) and lets the user choose which one to delete // then deletes the chosen watercraft from the list // decrements the list size // if list is empty, prints message that the list is empty Searching For And Printing Watercraft By Type Or Motor: int typeInInventory ( list_t *list, char whichOne [] ); // called by searchByType() function // search the list and return a 1 if that type is found, 0 if not found int motor InInventory ( list_t *list, int whichone); // called by searchByMotorType() function // search the list and return a 1 if that motor type is found, O if not found (0 for no motor, i for out-board motor, and 2 for in-board) void printWatrcraftByType( list_t *list, char whichone'] ); 71 traverses the list for the type that matches whichone and prints all found void printWatrcraftByMotor( list_t *list, int whichOne ); 7/ traverses the list for propulsion that matches whichone and returns all found void searchByType( list_t *list ); // prints choices of types for user to choose the desired one (e.g. 1 for pontoon, 2 for fishing, etc.) // uses if-else statement or switch statement to call typeInInventory() sending the list and the string for the type chosen (e.g. "pontoon" or "fishing", etc.) // if type In Inventory () returns a 1, call printWatercraftByType() void searchByMotorType( list_t *list ); // prints motor types for user to choose the desired one (e.g. 1 for no motor, 2 for out-board motor, 3 for in-board motor) // uses if-else statement or switch statement to call motorInInventory) sending the list and the integer for the type chosen (0, 1, or 2) // if type In Inventory () returns a 1, call printWatercraftByMotor Type() 1. load inventory of watercraft from file 2. add additional watercraft to front of list 3. add additional watercraft to end of list 4. number of watercraft in inventory 5. print inventory of watercraft 6. print specs of chosen watercraft 7. delete chosen watercraft 8. search watercraft by type 9. search watercraft by motor type 10. sort watercraft by price 11. total asset value in inventory 12. quit program Your program should contain the following files: 1. mainDriver.c (contains main() function) 2. sll_list.h (header file for this singly linked-list program provided to you) 3. sll_list.c implementation file for this doubly linked-list program) 4. watercraft.txt (contains watercraft for initializing your linked-list). The watercraft can be any kind of watercraft, such as pontoon, fishing, sport boat, sailboat, kayak, canoe, even ski jets (although there are no jet skis in the test file). You can add whatever types of watercraft that you want to the test file. Make sure that no fields are skipped, though. 5. makefile (Your makefile should have at least two targets: a compile target, which renames your executable to sll; and a clean target which removes the executable and any other un-needed files, like .o files if there are any) FUNCTION PROTOTYPES Initializing The List: int printMenu(); // prints the menu to the user; returns the menu choice list t *newList(); // creates a new list; initializes size, and head & tail pointers; returns a pointer to the new list void listInit( list_t *list, FILE *inFile ); // called from initializeFromFile(); call newWatercraft () to create and 17 initialize a new watercraft from the file; then add it to the end of // the list; increments the list size for each watercraft added void initialize FromFile( list t *list, FILE *inFile ); // calls listInit() sending the input file pointer (which is the file // specified at the command-line that was opened in the main() function) watercraft t *new waterCraft( FILE *in File); // called by listInit() function // creates and initializes a new watercraft node from the input file pointer sent in // returns a pointer to the watercraft that was just created Adding Additional Watercraft: void addToFront ( list_t *list ); // creates a new watercraft from user input and then adds it to the front of the list // increments the list size void addToRear( list_t *list ); // creates a new watercraft from user input and then adds it to the rear of the list; should use the tail pointer // increments the list size Printing Entire List Of All Watercraft Or Specs Of Chosen Watercraft: void printList ( list_t *list ); // prints all the watercraft in the list void print Specs ( list_t *list ); // prints a list of he watercraf (i.e.calls printListo) and asks user to choose which one to show the specs of // the specs will include the extra items and their associated costs, if applicable Deleting A Watercraft: void deleteWatercraft( list_t *list ); // prints the list of watercraft (i.e.calls printList()) and lets the user choose which one to delete // then deletes the chosen watercraft from the list // decrements the list size // if list is empty, prints message that the list is empty Searching For And Printing Watercraft By Type Or Motor: int typeInInventory ( list_t *list, char whichOne [] ); // called by searchByType() function // search the list and return a 1 if that type is found, 0 if not found int motor InInventory ( list_t *list, int whichone); // called by searchByMotorType() function // search the list and return a 1 if that motor type is found, O if not found (0 for no motor, i for out-board motor, and 2 for in-board) void printWatrcraftByType( list_t *list, char whichone'] ); 71 traverses the list for the type that matches whichone and prints all found void printWatrcraftByMotor( list_t *list, int whichOne ); 7/ traverses the list for propulsion that matches whichone and returns all found void searchByType( list_t *list ); // prints choices of types for user to choose the desired one (e.g. 1 for pontoon, 2 for fishing, etc.) // uses if-else statement or switch statement to call typeInInventory() sending the list and the string for the type chosen (e.g. "pontoon" or "fishing", etc.) // if type In Inventory () returns a 1, call printWatercraftByType() void searchByMotorType( list_t *list ); // prints motor types for user to choose the desired one (e.g. 1 for no motor, 2 for out-board motor, 3 for in-board motor) // uses if-else statement or switch statement to call motorInInventory) sending the list and the integer for the type chosen (0, 1, or 2) // if type In Inventory () returns a 1, call printWatercraftByMotor Type() 1. load inventory of watercraft from file 2. add additional watercraft to front of list 3. add additional watercraft to end of list 4. number of watercraft in inventory 5. print inventory of watercraft 6. print specs of chosen watercraft 7. delete chosen watercraft 8. search watercraft by type 9. search watercraft by motor type 10. sort watercraft by price 11. total asset value in inventory 12. quit program
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started