Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Rectangle.hpp"
- #include "Figure.hpp"
- #include <cassert>
- #include <iostream>
- #include <cmath>
- Rectangle::Rectangle(int id, int x, int y, int width, int height) : Figure(id, x, y){
- this->width = width;
- this->height = height;
- }
- void Rectangle::print() const{
- std::cout << "Rectangle " << this->id << ": x = " << this->x << " y = " << this->y << " width = " << this->width << " height = " << this->height << std::endl;
- }
- bool Rectangle::is_inside(int x, int y) const{
- return 2 * abs(this->x - x) <= this->width && 2 * abs(this->y - y) <= this->height;
- }
- void Rectangle::zoom(int factor){
- assert(factor > 0);
- this->width *= factor;
- this->height *= factor;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement