-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNephroid_main.cpp
More file actions
65 lines (63 loc) · 1.58 KB
/
Nephroid_main.cpp
File metadata and controls
65 lines (63 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#include <iostream>
#include <iomanip>
#include "Nephroid.h"
int main() {
lab1b::Nephroid c;
lab1b::Point p;
int fl1 = 1;
double r;
std::string s;
while (fl1) {
std::cout << std::fixed << std::setprecision(2);
std::cout << "Nephroid's equation is: " << std::endl;
s = c.equation();
std::cout << s;
std::cout << "area: " << c.area() << std::endl;
std::cout << "perimeter: " << c.length() << std::endl;
int fl2 = 1;
while (fl2) {
std::cout << "Enter t to calculate the radius of curvature and coordinatses or press ctrl+Z to quit:" << std::endl;
double t;
lab1b::Point cords;
std::cin >> t;
fl2 = std::cin.good();
if (!fl2)
continue;
try {
std::cout << "Radius of curvature: " << std::setprecision(4) << c.curveradius(t) << std::endl;
cords = c.coordinates(t);
std::cout << "Coordinates: " << "x = " << cords.x << ", y = " << cords.y << std::endl;
}
catch (std::exception & ex)
{
std::cout << ex.what() << std::endl;
}
}
std::cin.clear();
std::cout << "Enter new x, y and r to continue or press ctrl+Z to quit:" << std::endl;
std::cin >> p.x >> p.y >> r;
if (std::cin.good()) {
c.setP(p);
try {
c.setR(r);
}
catch (std::exception& ex)
{
std::cout << ex.what() << std::endl;
std::cin.clear();
std::cin.ignore(INT_MAX, '\n');
continue;
}
}
else {
std::cout << "Incorrect input detected, the program will close";
fl1 = 0;
}
}
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG);
_CrtDumpMemoryLeaks();
return 0;
}