@@ -6,7 +6,7 @@ using namespace std;
66
77// class Point
88
9- Point::Point (int x, int y):
9+ Point::Point (double x, double y):
1010 x(x), y(y) {
1111}
1212
@@ -17,16 +17,21 @@ ostream& operator<<(ostream &out, Point &p) {
1717
1818// class Shape
1919
20- Shape::Shape (int id, Point pos):
21- id(id), pos(pos) {
20+ Shape::Shape (Point pos):
21+ id(next_id()), pos(pos) {
22+ }
23+
24+ unsigned long Shape::next_id () {
25+ static unsigned long next_id = 0 ;
26+ return next_id++;
2227}
2328
2429void Shape::print () {
2530 cout << " id: " << id << endl;
2631 cout << " pos: " << pos << endl;
2732}
2833
29- int Shape::get_id () {
34+ unsigned long Shape::get_id () {
3035 return id;
3136}
3237
@@ -40,8 +45,8 @@ bool Shape::operator==(Shape &s) {
4045
4146// class Circle
4247
43- Circle::Circle (int id, Point pos, int r, string text):
44- Shape(id, pos), r(r), text(text) {
48+ Circle::Circle (Point pos, double r, string text):
49+ Shape(pos), r(r), text(text) {
4550}
4651
4752void Circle::print () {
@@ -57,8 +62,8 @@ double Circle::get_contour_length() {
5762
5863// class Segment
5964
60- Segment::Segment (int id, Point start, Point end):
61- Shape(id, start), start(start), end(end) {
65+ Segment::Segment (Point start, Point end):
66+ Shape(start), start(start), end(end) {
6267}
6368
6469void Segment::print () {
0 commit comments