Arsylk

Narkoman Records

Apr 11th, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <sstream>
  4.  
  5. using namespace std;
  6.  
  7. class Surface {
  8.   private:
  9.     float width, height;
  10.  
  11.   //methods
  12.   public:
  13.     float getSurface() {
  14.       return width * height;
  15.     }
  16.  
  17.   //getter & setter
  18.   public:
  19.     float getWidth() {
  20.       return width;
  21.     }
  22.     float getHeight() {
  23.       return height;
  24.     }
  25.  
  26.     void setWidth(float width) {
  27.       this->width = width;
  28.     }
  29.     void setHeight(float height) {
  30.       this->height = height;
  31.     }
  32. };
  33.  
  34. class Painting {
  35.   private:
  36.     float plnSqMeter;
  37.  
  38.   //getter & setter
  39.   public:
  40.     float getPlnSqMeter() {
  41.       return plnSqMeter;
  42.     }
  43.  
  44.     void setPlnSqMeter(float plnSqMeter) {
  45.       this->plnSqMeter = plnSqMeter;
  46.     }
  47. };
  48.  
  49. class PaintedSurface : public Surface, public Painting  {
  50.   public:
  51.     float getPrice() {
  52.       return Surface::getSurface() * Painting::getPlnSqMeter();
  53.     }
  54. };
  55.  
  56. int main() {
  57.   PaintedSurface ps;
  58.   ps.setWidth(10);
  59.   ps.setHeight(5);
  60.   ps.setPlnSqMeter(3.9);
  61.   cout << ps.getPrice();
  62.  
  63.   return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment