Skip to content

Commit

Permalink
Change task 2
Browse files Browse the repository at this point in the history
  • Loading branch information
KachalovM committed Sep 27, 2024
1 parent acddc21 commit 313b4ee
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
25 changes: 12 additions & 13 deletions include/circle.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@
#include <cstdint>

class Circle {
private:
double radius;
double ference;
double area;
private:
double radius;
double ference;
double area;

public:
explicit Circle(double r);
public:
explicit Circle(double r);

void setRadius(double r);
void setFerence(double f);
void setArea(double a);
void setRadius(double r);
void setFerence(double f);
void setArea(double a);

double getRadius() const;
double getFerence() const;
double getArea() const;
double getRadius() const;
double getFerence() const;
double getArea() const;
};


#endif // INCLUDE_CIRCLE_H_
7 changes: 1 addition & 6 deletions src/tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,22 @@

double solveEarthAndRope(double earthRadius) {
Circle earth(earthRadius);

double newFerence = earth.getFerence() + 1;

Circle ropeCircle(earthRadius);
ropeCircle.setFerence(newFerence);

double gap = ropeCircle.getRadius() - earth.getRadius();

return gap;
}

double solveSwimmingPool(double poolRadius, double walkwayWidth) {

Circle pool(poolRadius);

Circle poolWithWalkway(poolRadius + walkwayWidth);

double walkwayArea = poolWithWalkway.getArea() - pool.getArea();

double concreteCost = walkwayArea * 1000;

double fenceCost = poolWithWalkway.getFerence() * 2000;

return fenceCost + concreteCost;
Expand Down
3 changes: 3 additions & 0 deletions test/tests.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// Copyright 2024 Kachalov Mikhail
#include <gtest/gtest.h>
#include <cstdint>
#include <cmath>
#include "circle.h"
#include "tasks.h"

const double PI = 3.14159265358979323846;

TEST(CircleTest, SetRadius) {
Circle circle(10);
EXPECT_DOUBLE_EQ(circle.getRadius(), 10);
Expand Down

0 comments on commit 313b4ee

Please sign in to comment.