Scalable Cross-Platform Software Design 2020: Generic Programming Coursework#1
25% of the module mark in total: Marking Scheme and submission deadline is on Moodle
Please Note: No report is required. Just submit 1 file per task, all zipped together. All questions are drawn from actual codes I have written for clients – just to reassure you of their “reality” In file comments. I will not mark you down for no comments, but, if, as an experienced coder, I cannot
immediately understand what you are doing and why, imagining that I were tasked with maintaining it in the
future, you will lose marks on that task. Subsequently sending me an “explanation” – well that’s not the real
world – will not be acceptable. I require you to write a test main for each task that demonstrates example use. I will compile and test on MSYS2. A gentle warning: I am very good at spotting codes that have been lifted from the internet or written by computer
scientist friends. To protect the integrity of the assessment and the efforts of the vast majority of students who
will do the assessment themselves I am obliged to report any such violations of the University’s plagiarism rules. Be careful of cutting & pasting from pdfs into code – it can sometimes embed hidden control characters causing
weird compiler errors.
Marks and feedback will be provided 15 working days after the submission deadline; each student will receive an
individual copy of the marking rubric posted on Moodle by email. If required, further individual feedback is then
available by requesting a one-to-one meeting.
Task1: Demonstrate basic implementation of a templated function (25% of the assessment mark)
Write a templated function, called wrapAround, that accepts one unsigned integer argument, i. The intention is that
i is being used by the function caller to index elements in an array.
The return value is to be i+N unless i+N is greater than or equal to M, in which case, the return value wraps around
back to 0 and beyond. We can assume(!) that i is positive and less than M. N and M can take any unsigned integer
values.
Example: N=2, M=3
i=0, returns 2
i=1, returns 0
i=2, returns 1
Example: N=3, M=5
i=0, returns 3
i=1, returns 4
i=2, returns 0
i=3, returns 1
i=4, returns 2
Task 2: Demonstrate basic implementation of simple functors (25% of the assessment mark)
A 2D geometry manipulation code uses templated functions and classes to generate lines in the “x-y” plane, e.g.
template
void plot(const CURVE & c){
float x,y;
for(float t=0; t<1;t+=0.01) {
c(t,x,y); // Given t, evaluate x and y values
cout<< ”\n”<