Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include "Rectangle.hpp"
  2. #include "Figure.hpp"
  3. #include <cassert>
  4. #include <iostream>
  5. #include <cmath>
  6.  
  7.  
  8. Rectangle::Rectangle(int id, int x, int y, int width, int height) : Figure(id, x, y){
  9. this->width = width;
  10. this->height = height;
  11. }
  12.  
  13. void Rectangle::print() const{
  14. std::cout << "Rectangle " << this->id << ": x = " << this->x << " y = " << this->y << " width = " << this->width << " height = " << this->height << std::endl;
  15. }
  16.  
  17. bool Rectangle::is_inside(int x, int y) const{
  18. return 2 * abs(this->x - x) <= this->width && 2 * abs(this->y - y) <= this->height;
  19.  
  20. }
  21.  
  22. void Rectangle::zoom(int factor){
  23. assert(factor > 0);
  24. this->width *= factor;
  25. this->height *= factor;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement