You are expected to complete this assignment individually. If you need help, you are invited to come to office hours and/or ask questions on piazza. Clarification questions about the assignments may be asked publicly. Once you have specific bugs related to your code, make the posts private.
This homework has several problems. We are also providing you with some resources on printf and error handling for this assignment.
You should submit four files for this assignment ( hw6.h, hw6.c, hw6_main.c, and Makefile) in your subversion repository as directed below.
You already created hw6.c and hw6.h in the warmup. Continue adding to those files for this homework.
You need to add the skeleton code so that your program will minimally execute. You must do this in case you do not complete your assignment. Our testing infrastructure needs to compile and execute even if you did not complete the entire assignment. Refer to past assignments on how to make skeleton code.
Write a function that, given a productID, records a single item as restocked. That is, it replaces the current number of items with the max number of items after restocking.
void record_restocked_single(node *head, uint pID);
Write a function that, given a productID, finds the record for the product and decrements the number of items currently in stock for that item.
void product_sold(node *head, uint pID);
In a previous assignment, you implemented an insertion sort on an array. You accomplished this by not sorting the unsorted list, but inserting an item, one at a time, into the sorted section of the array. This work hinged on knowing that the items that had already been inserted were sorted, and the only job was to place this new item in the right place. We are sorting the same way.
Note: I am not asking you to sort an existing, unsorted linked list. We will also not test your function by calling it with an unsorted list.
You are going to write two different insert functions - one that inserts into sorted order by productID and one that inserts into sorted order by category and then productID. That is, it inserts it immediately prior to the first product it finds with a larger productID than it has. If there are no product with larger productIDs, then it places it at the end of the list.
For the items sorted by category and then productID, the order of categories is the same as the enumerated type - GROCERY products come first, followed by OFFICE, PHARMACY, and finally HOBBY. Within each category, however, the multiple items of the same category must be sorted, with smallest productIDs closer to the head of the list.
It returns a pointer to the beginning of the modified list.
node *add_sorted_productID(product_info *pinfo, node *head); node *add_sorted_category_ID(product_info *pinfo, node *head);
Every week, when the store makes restock orders, it needs to go through and find all of the items that have fallen below the min_for_restock. There may be multiple items, so you need to make a new linked list of items that need to be restocked. Note that the nodes hold pointers to the product_info records, not the records themselves, so you can safely have multiple linked lists with pointers to the same records without destroying the original linked list.
Implement a function that will create a linked list of product_info records that need to be restocked (current_stock < min_for_restock). Return the head of this new linked list. Do not make any modifications to the original linked list. If there is nothing to restock, or the original list is empty, then return NULL.
node *make_restock_list(node *head);
Once the restocked items arrive, all items that were restocked need to have their current_stock reflect the new items that came in. Given a list of restocked items, go through the original list and record the current_stock value to be equal to max_after_restock.
void record_restocked_list(node *restocked_list, node *head);
$ svn add hw6.h hw6.c hw6_main.c Makefile
$ svn commit -m "hw6 complete"