Compare commits
No commits in common. "c6e005ec1bed6bbbe9bbad0f362b8863d9da827f" and "b0458db7437b34b78fbf89f6828f22520f05e2d4" have entirely different histories.
c6e005ec1b
...
b0458db743
@ -1,19 +0,0 @@
|
||||
//
|
||||
// Created by ahypki on 28.03.23.
|
||||
//
|
||||
|
||||
#include "Figure.h"
|
||||
|
||||
namespace ahypki {
|
||||
std::string Figure::getName() {
|
||||
return this->name;
|
||||
}
|
||||
|
||||
void Figure::setName(std::string newName) {
|
||||
this->name = newName;
|
||||
}
|
||||
|
||||
double Figure::computeArea() {
|
||||
return 0.0;
|
||||
}
|
||||
} // ahypki
|
23
cpp/Figure.h
23
cpp/Figure.h
@ -1,23 +0,0 @@
|
||||
//
|
||||
// Created by ahypki on 28.03.23.
|
||||
//
|
||||
#include <iostream>
|
||||
|
||||
#ifndef TESTCPPPROGOBIE_FIGURE_H
|
||||
#define TESTCPPPROGOBIE_FIGURE_H
|
||||
|
||||
namespace ahypki {
|
||||
|
||||
class Figure {
|
||||
private:
|
||||
std::string name = "Unknown figure";
|
||||
public:
|
||||
std::string getName();
|
||||
void setName(std::string newName);
|
||||
virtual double computeArea();
|
||||
virtual double pureVirtualComputeArea() = 0;
|
||||
};
|
||||
|
||||
} // ahypki
|
||||
|
||||
#endif //TESTCPPPROGOBIE_FIGURE_H
|
@ -1,32 +0,0 @@
|
||||
//
|
||||
// Created by ahypki on 28.03.23.
|
||||
//
|
||||
|
||||
#include "Square.h"
|
||||
|
||||
namespace ahypki {
|
||||
Square::Square() {
|
||||
setName("Square");
|
||||
}
|
||||
|
||||
Square::Square(double x) {
|
||||
setName("Square");
|
||||
setX(x);
|
||||
}
|
||||
|
||||
double Square::getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
void Square::setX(double newX) {
|
||||
x = newX;
|
||||
}
|
||||
|
||||
double Square::computeArea() {
|
||||
return getX() * getX();
|
||||
}
|
||||
|
||||
double Square::pureVirtualComputeArea() {
|
||||
return getX() * getX();
|
||||
}
|
||||
} // ahypki
|
26
cpp/Square.h
26
cpp/Square.h
@ -1,26 +0,0 @@
|
||||
//
|
||||
// Created by ahypki on 28.03.23.
|
||||
//
|
||||
|
||||
#include "Figure.h"
|
||||
|
||||
#ifndef TESTCPPPROGOBIE_SQUARE_H
|
||||
#define TESTCPPPROGOBIE_SQUARE_H
|
||||
|
||||
namespace ahypki {
|
||||
|
||||
class Square : public Figure {
|
||||
private:
|
||||
double x;
|
||||
public:
|
||||
Square();
|
||||
Square(double x);
|
||||
void setX(double x);
|
||||
double getX();
|
||||
virtual double computeArea();
|
||||
virtual double pureVirtualComputeArea();
|
||||
};
|
||||
|
||||
} // ahypki
|
||||
|
||||
#endif //TESTCPPPROGOBIE_SQUARE_H
|
22
cpp/main.cpp
22
cpp/main.cpp
@ -1,22 +0,0 @@
|
||||
#include <iostream>
|
||||
#include "Figure.h"
|
||||
#include "Square.h"
|
||||
|
||||
int main() {
|
||||
std::cout << "Hello, World!" << std::endl;
|
||||
|
||||
// ahypki::Figure figure = ahypki::Figure();
|
||||
// std::cout << "Default name: " << figure.getName() << std::endl;
|
||||
//
|
||||
// figure.setName("Next name");
|
||||
// std::cout << "New name: " << figure.getName() << std::endl;
|
||||
|
||||
ahypki::Square s = ahypki::Square(10);
|
||||
std::cout << s.getName()
|
||||
<< " has x= " << s.getX()
|
||||
<< " has area= " << s.computeArea()
|
||||
<< std::endl;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user