spod

Security Engineer

Home About Resume Projects

yea um… this might be C++…

#include <iostream>
using namespace std;

class Rectangle {
    int width, height, complex_volume;
  public:
    void set_values (int,int);
    int calculate_complex_volume(Rectangle);
    int area () {return width*height;}
};

void Rectangle::set_values (int x, int y) {
  width = x;
  height = y;
}

int Rectangle::calculate_complex_volume(Rectangle other) {
    int sum = 0;
    
    int type = 0;

    scanf("%d", &type);
    
    for(int i = 0; i < 5; i++) {
        if (type == 0) {
            return -1;
        }
        if (type == 1) {
            sum += (width * other.width);
            sum += (width * other.height);
            sum += (width * other.area());
            sum %= height;
        }
        else if (type == 2) {
            sum += (width * other.width);
            sum += (width * other.height);
            sum += (width * other.area());
            sum %= other.height;
        }
        else {
            return 1;
        }
    }

    complex_volume = sum;
    return sum;
}

int main () {
  Rectangle rect, rectb;
  rect.set_values (3,4);
  rectb.set_values (5,6);
  rect.calculate_complex_volume(rectb);
  return 0;
}