20 lines
725 B
C++
20 lines
725 B
C++
#include "block.h"
|
|
|
|
Block::Block(int constructionYear, int totalApartments, int occupiedApartments){
|
|
this->constructionYear = constructionYear;
|
|
this->totalApartments = totalApartments;
|
|
this->occupiedApartments = occupiedApartments;
|
|
}
|
|
|
|
bool Block::mustBeRestored(){
|
|
return (this->constructionYear < 1987) && (this->occupiedApartments/this->totalApartments>0.8);
|
|
}
|
|
|
|
bool Block::canBeDemolished(){
|
|
return (this->occupiedApartments/this->totalApartments<0.05);
|
|
}
|
|
|
|
std::string Block::toString(){
|
|
return "Block built in: " + std::to_string(this->constructionYear) + " with " + std::to_string(this->totalApartments) + " apartments, of which " + std::to_string(this->occupiedApartments) + " are occupied.";
|
|
}
|