Wednesday, October 11
Compiling the assignment and doing a sanity check
Assuming that your a2.c and a2.h are organized
as per the assignment, you can create a separate test program, say,
in a file called main.c . A sample main.c
can be found here.
To compile main.c with your code from a2.c
and a2.h , use:
gcc a2.c main.c -lm -o main
To run the test program, use:
./main
Assuming that you have correctly implemented all the functions, you
should get this output.
Comments are necessary!
Documentation is worth 25% of the mark, as per the assignment sheet.
You won't be producing external documentation, but you will need internal
documentation, i.e. comments.
Read the general programming assignment guidelines, as well as the
lectures slides on how to write good comments, to double-check that
your documentation is OK.
Tuesday, October 10
Clarification on return value of rectangleUnion
and rectangleIntersection
rectangleUnion returns the bounding rectangle (using the
same type of calculation as in Assignment 1) of its two arguments. rectangleIntersection
returns the rectangle which is the overlap between its two arguments.
Note that if the edges of the rectangles touch but nothing else, there
is no intersection. (Note that there would be a union.)
If no union or intersection exists, then you should return a rectangle
with width and height of 0 , and a centre of (0, 0) .
Friday, October 6
New minimum number of rectangles for RectangleList
In the interests of having your programs use less system resources,
you can change the minimum number of rectangles for RectangleList
to 50. I'm not going to test RectangleList with more than
50 rectangles.
rectangleListArea (non-trivial
case) will now count as bonus
It's official. The non-trivial implementation of rectangleListArea ,
that is, summing the areas of the rectangles but counting overlapping
areas only once, will now be counted for bonus (relative weighting to
be determined).
If you want a hint, you might want to research the Principle of
Inclusion and Exclusion from set theory.
Creating functions other than the ones requested
in the assignment
This is OK if these extra functions serve as helpers for the functions
requested in the assignment. In fact, if your implementation for a function
is rather long, you may want to consider making a helper function.
Using pointers
You cannot use pointers in the type definitions as per note 3 in the
assignment specification. Note that this also means that none of the
functions requested in the assignment can take pointers as arguments
or return pointers.
However, if you know what you are doing, then you may use pointers
for implementation of functions. You will not be given
extra credit, and in fact you may lose marks if the marker determines
that you do not know what you are doing.
You are well-advised to keep things simple and avoid using pointers
for this assignment. You will have plenty of opportunities later on
to use pointers. :-)
Monday, October
Correction for rectangleListArea prototype
The following prototype is incorrect:
Rectangle rectangleListArea(const RectangleList rl, const boolean
discountOverlap)
It should be:
double rectangleListArea(const RectangleList rl, const boolean
discountOverlap)
Return value of rectangleListUnion
and rectangleListIntersection if RectangleList
argument has zero rectangles
If the rectangle list passed to rectangleListUnion or
rectangleListIntersection has zero rectangles, then you
should return a rectangle with width and height of 0 , and
a centre of (0, 0) .
Maximum number of rectangles for RectangleList
There is no maximum.
Handling illegal (out-of-bounds) indices for the
rectangleListGet , rectangleListSet and rectangleListSubList
functions
Use assert() to handle illegal index arguments for rectangleListGet ,
rectangleListSet and rectangleListSubList :
RectangleList Function |
Illegal values for arguments
(n : size of list) |
rectangleListGet(rl, i) |
(i < 0) || (i >= n) |
rectangleListSet(rl, r, i) |
(i < 0) || (i >= n) |
rectangleListSubList(rl, a, b) |
(a < 0) || (b > n) || (a > b) |
Note that for rectangleListSubList , if a == b ,
then you return an empty list.
|