Lab 1
Warning
To compile you should use a CMakeLists.txt. It takes sometimes to get use to it, but it makes the compilation much easier.
Class templates
Create a class template
Positionthat will store the position in a 2D environment. The position can beintorfloat, etc.Create a class template
Rectanglethat will contain the origin position and the size of the rectangle. For the size use the class position too.Create the a function
getArea()that will calculate and return the area.Create the getters and setters.
Define the following operators for the class
Position:operator==operator<, we want to compare the area.operator>, we want to compare the area.
Function templates
Create a function template
const Comparable& findMax(const vector<Comparable>& a).This function should be able to accept a vector of
Rectangleand return the one the maximum area.Create a function
int BinarySearch(const vector<Comparable>& a, const Comparable &x). That allow to search for a rectangle in an ordered vector of rectangle.
LeetCode
If you are done you can start doing the following problems on LeetCode:
ENSURE WE HAVE RECORDED YOUR COMPLETION. FAILURE TO DO SO WILL RESULT IN A GRADE OF 0!