AP9_Box.h

1
2
3
4
5
6
7
8
9
class Box {
    int width, height;
    char fill;
public:
    Box(int w, int h) { setSize(w, h); fill = '*'; }
    void setFill(char f) { fill = f; }
    void setSize(int w, int h) { width = w; height = h; }
    void draw();
};
cs

AP9_Box.cpp

1
2
3
4
5
6
7
8
9
10
#include <iostream>
#include "AP9_Box.h"
using namespace std;
 
void Box::draw() {
    for (int n = 0; n < height; n++) {
        for (int m = 0; m < width; m++)cout << fill;
        cout << endl;
    }
}
cs

AP9_main.cpp

1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
#include "AP9_Box.h"
using namespace std;
 
int main() {
    Box b(102);
    b.draw();
    cout << endl;
    b.setSize(74);
    b.setFill('^');
    b.draw();
}
cs


+ Recent posts