A Rectangle ADT (and practicing git)
In this lab you will be implementing an ADT Rectangle accoring to the following UML:
+================================================================+
| Rectangle |
| ---------------------------------------------------------------|
| - x0, y0: int // coordinates of the lower left corner |
| - x1, y1: int // coordinates of the top right corner |
| ---------------------------------------------------------------|
| + Rectangle() |
| + Rectangle(xx0: int, yy0: int, xx1: int, yy1: int) |
| + area(): int |
| + perimeter(): int |
| + operator<(Rectangle): bool |
| + operator+(Rectangle): Rectangle |
| + scale(factor: int): void |
| + display(): void |
+================================================================+
Some notes:
- A rectangle is less than other if its center is closer to the origin.
- The sum of two rectangles is the smallest rectangle that contains both.
- The scale operation leaves the lower left corner in place and affects the upper right
We will be using git as a version control system and a way for you to submit your completed work.
Download the skeleton code
If you don't have already, create an account in github.com. Please use your upr.edu email username for the account.
Login to your github account.
Visit the assignment link https://classroom.github.com/a/HRCM-BT-
You will be shown a welcome message similar to this:
Click the Accept this assignment. Then you will see something similar to this:
Click the address in blue, which will take you to the you github repository copy of the assignment:
Grab the address from the browser address bar and paste it in the command line to clone the directory:
git clone https://theURLyoucopyfromTheAdddressBar
Change to the directory you have just cloned
cd theNameOfTheDirectory
... and check to see if it contains the files:
ls
catch.hpp CMakeLists.txt main.cpp README.md Rectangle.cpp Rectangle.h
Working on the downloaded files
Depending on your choice of IDE, do one of the following.
Using CLion
Use the option "Open Project" and open the folder that was just created by the git clone.
Using QtCreator
Use the option "Open File or Project" then navigate to the folder and open the file CMakeLists.txt
. This is will instruct QTCreator to configure the project.
Using the command line
Use your favorite editor to edit the code. To compile, use cmake .
followed by Makefile
.
Now let's code!!!
Class declaration
In the file Rectangles.h
, code the class declaration for the Rectangle ADT. Do not implement any member functions yet.
When you finish the class declaration do the following (in the command line) to submit your changes to github:
git add
git commit -m "declaration"
git push origin master
Class member functions implementation
Implement half of the member functions with their corresponding tests in the client. Then commit your changes using:
git add
git commit -m "implementations 1 of 2"
git push origin master
Implement the rest of the functions with their corresponding tests in the client. Then commit your changes using:
git add
git commit -m "implementations 2 of 2"
git push origin master