Code Correctness
As always, this assignment has a particular set of design features that we expect you to focus on. This time, there is only one new one: code duplication. We strongly expect that you will be tempted to have multiple files with a significant resemblance to each other. Don’t do it. You’ve been warned. Here’s the list of the other design features we’ve already highlighted:
- good variable and function names
- procedural decomposition
- “overcommenting” (e.g., the comments do not explain things that are already clear from the code itself)
- usage of whitespace
- overmodularization (e.g., modularizing into functions that actually make the code less clear)
Deliverable
Generic List
This week, you will apply the concepts you’ve learned in lecture about void *
abstraction to create a generic list that can store any type of object. In addition, you will need slightly better abstractions (in particular, you will need some kind of resizing for your list) than you did last week, and we expect you to spend a significant amount of the project time on improving them.
Note that since the generic list builds off your team’s implementation of vector list in week 1, you should read and understand your team’s implementation of vec_list_t
and repurpose the code for list_t
. In other words, do NOT write your code for the generic list from scratch; use the code for vec_list_t
as a starting point and modify it to fit the new list_t
interface.
You may not remove or edit signatures of functions in the interfaces in list.h
!!!! You may add functionality if you deem it necessary.
If you find yourself spending very little time on implementing list_t
, something about your architecture probably needs to be modified.
The underlying structure of list_t
cannot be a linked list; it must be array based.
Polygon
Instead of just representing polygons as vec_list_t
’s, we’ll want to create a struct for them in an effort to make our code more encapsulated. Among other benefits, we’ll then be able to access values like its velocity, center, rotation, etc. more easily without having to recalculate them each time.
Again, use your team’s current implementation of polygons as a foundation for your code and modify it so that it fits the new polygon_t
interface.
Color and Vector
We have provided a color
implementation for you that should be helpful for completing your task for this week.
You do not need to rewrite vector
and should instead copy over your vector
implementation from last week.
Testing
We have given you tests for the generic list and polygon that must be passed in order to receive full credit. The vector and color tests have been provided as sanity checks.
As a reminder, to run all the tests, all you need to type is make test
. To run compile and run an individual test suite, run the following commands (replacing vector
with the test suite you want to run)
:
make bin/test_suite_vector
./bin/test_suite_vector
Task 0. When you are done, your group should meet and complete the questions here.