wes d2a2ba9e15 first commit | 4 سال پیش | |
---|---|---|
.. | ||
README.md | 4 سال پیش | |
code.cpp | 4 سال پیش | |
unitTest.cpp | 4 سال پیش |
by Alex Golubov tags: objects, classes, math
Your task is to create a Circle constructor that creates a circle with a radius provided by an argument. The circles constructed must have two getters getArea() (PIr^2) and getPerimeter() (2PI*r) which give both respective areas and perimeter (circumference). For help with this class, I have provided you with a Rectangle constructor which you can use as a ba
Your task is to create a Circle constructor that creates a circle with a radius provided by an argument. The circles constructed must have two getters getArea()
(PI*r^2) and getPerimeter()
(2*PI*r) which give both respective areas and perimeter (circumference).
For help with this class, I have provided you with a Rectangle constructor which you can use as a base example.
Circle circy(11);
circy.getArea();
// Should return 379.94
Circle circy(4.44);
circy.getPerimeter();
// Should return 27.8832
Don't worry about floating point precision - I've factored in the chance that your answer may be more or less accurate than mine. This is more of a tutorial than a challenge so the topic covered may be considered advanced, yet the challenge is more simple - so if this challenge gets labelled as easy, don't worry too much.