consolidate all repos to one for archive
This commit is contained in:
36
semester_2/programiranje_2/naloga0601/Rectangle.cpp
Normal file
36
semester_2/programiranje_2/naloga0601/Rectangle.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// Created by Nik on 10/04/2022.
|
||||
//
|
||||
|
||||
#include "Rectangle.h"
|
||||
#include <cmath>
|
||||
|
||||
Rectangle::Rectangle(ColorCode color, unsigned int width, unsigned int height) :
|
||||
Shape2D(color), width(width), height(height) {}
|
||||
|
||||
Rectangle::Rectangle(ColorCode color, unsigned int size) :
|
||||
Shape2D(color), width(size), height(size) {}
|
||||
|
||||
unsigned int Rectangle::getSurfaceArea() const {
|
||||
return width * height;
|
||||
}
|
||||
|
||||
void Rectangle::draw() const {
|
||||
for (int i = 0; i < height; i++) {
|
||||
PrintUtility::print(color, width);
|
||||
std::cout << "\n";
|
||||
}
|
||||
std::cout << "\n";
|
||||
}
|
||||
|
||||
std::string Rectangle::getString() const {
|
||||
std::string ret;
|
||||
for (int i = 0; i < height; i++) {
|
||||
for (int j = 0; j < width; j++) ret += " *";
|
||||
ret += "\n";
|
||||
}
|
||||
ret += "\n";
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user