You will interact with a custom data representation for keeping track of things in a store, implementing functions using bitwise operators, pointers, and arrays.
This lab uses a custom data representation of aisles in a store.
aisle_manager.c and store_client.c have
skeleton functions for you to implement, each with a comment
describing its desired behavior.
You will start by implementing functions that use bitwise operators, bitmasks, and C control structures to manage an individual aisle. After implementing these functions, you will move onto functions that use pointers, arrays, and your aisle functions to manage multiple aisles in a store. We have provided two test programs to help you check the correctness of your work (see Checking Your Work for more details).
This isn't a programming course and we generally won't be checking your style. However, for this lab we will do a quick check for the following items, with the intent of helping you avoid introducing unnecessary bugs. This will be worth just 1 point and is intended to be relatively stress-free.
get_* and set_* functions.
Start by reading the description of an aisle's data representation
at the top of aisle_manager.c.
Make sure you fully understand the layout of the
representation before continuing.
If you have any questions, please post on the message board or come
to office hours.
Once you understand the data representation, you can begin to
implement the skeleton functions in aisle_manager.c:
get_sectionget_spacesget_idset_sectionset_spacesset_idtoggle_spacenum_itemsadd_itemsremove_itemsrotate_items_leftrotate_items_rightDo not be discouraged by the number of functions! They build gradually in level of difficulty, and many of them are similar to each other. Here's one recommended way of working through the file:
get_* and
set_* functions.
At this point you should be able to pass all tests in the
aisle_test executable!
Now you can move onto store_client.c.
store_client.c has some functions for interacting with
a group of aisles and a stockroom in the store.
Pay particular attention to its use of global arrays:
(1) of type unsigned long to represent multiple aisles
and (2) of type int to represent a stockroom for the
store (items stowed away that are not in the aisles).
Skeleton functions:
refill_from_stockroomfulfill_orderempty_section_with_idsection_with_most_items
At this point you should be able to pass all tests in the
store_test executable!
This means you are done with the programming part of the assignment
(don't forget about the synthesis questions!).
We have included the following tools to help you check the correctness of your work:
print_binary_long and
print_binary_short take an unsigned long
and unsigned short, respectively, and output its
binary representation.
These are optional to use but can be useful in debugging your code.
All calls to these functions should be removed from your final
submission.
Here is an example usage of print_binary_long
(print_binary_short works similarly except it takes
an unsigned short as its argument):
void print_binary_example(unsigned long* argument) {
// Print out binary view of argument for debugging.
// The type of argument is unsigned long*, so we
// must pass its dereference to print_binary_long.
print_binary_long(*argument);
}
printf to debug your functions,
but you'll have to add #include <stdio.h> at the
top of your file.
All calls to printf should be removed from your
final submission.
aisle_test and store_test are programs
that check the functional correctness of the code
in aisle_manager.c and store_client.c,
respectively.
make command.
To test all of the functions, use the following commands:
$ ./aisle_test $ ./store_test
The test one function at a time, use the -f flag on
the appropriate executable, e.g.:
$ ./aisle_test -f set_id $ ./store_test -f section_with_most_items
aisle_test and store_test first test
your solution on specific cases, and then on a wide range of
inputs.
As a manner of limiting the test output, for the range of inputs
the testing program will only print out the first input that your
solutions are incorrect for (or no input if you pass all cases).
lab1Bsynthesis.txt!
y is
purposefully omitted):
y = -1;y = 0xFFFFFFFF;
You will submit:
aisle_manager.c,
store_client.c,
and
lab1Bsynthesis.txt.
Be sure to run make clean and then make
on your code before submitting!
Submissions that don't compile will automatically receive a score
of ZERO.
After submitting, please wait until the autograder is done running and double-check that you passed the "File Check" and "Compilation and Execution Issues" tests. If either test returns a score of -1, be sure to read the output and fix any problems before resubmitting. Failure to do so will result in a programming score of ZERO for the lab.
Submit your files to the "Lab 1b" assignment on . Don't forget to add your partner, if you have one.