1919// * Segment: координаты начала и коодинаты конца
2020
2121// ? исправить: сделать чтобы айдишники задавались по умолчанию автоматически
22- // ? доп: написать функцию сравнения длин контуров двух фигур
23- // (круг сравнивать с отрезком -> длина окружности сравнивается с длиной отрезка)
22+ // ? доп: написать функцию сравнения длин контуров(!) двух фигур
23+ // ? (круг сравнивать с отрезком -> длина окружности сравнивается с длиной отрезка)
2424
2525#include " shape.h"
26+ #include " list.h"
2627
2728int main () {
2829 FigureList list;
2930
30- Circle *c_1 = new Circle (42 , {0 , 0 }, 1 , " lol kek" );
31- Circle *c_2 = new Circle (24 , {4 , 2 }, 7 , " cheburek" );
32- Segment *s_1 = new Segment (1 , {0 , 0 }, {42 , 42 });
31+ cout << endl << " ---- id_2 id_1 id_0 -> [] ----" << endl;
3332
34- list. push_front (c_1 );
35- list. push_front (c_2 );
36- list. push_front (s_1 );
33+ Circle *c1 = new Circle ({ 0 , 0 }, 1 , " lol kek " );
34+ Circle *c2 = new Circle ({ 4 , 2 }, 7 , " cheburek " );
35+ Segment *s1 = new Segment ({ 0 , 0 }, { 42 , 42 } );
3736
38- list.print_all ();
37+ list.push_front (c1);
38+ list.push_front (c2);
39+ list.push_front (s1);
3940
40- cout << endl << " ---------- " << endl;
41+ list. print_all (); // list now: [id_2, id_1, id_0]
4142
42- list.push_back (new Segment (2 , {6 , 18 }, {4 , 2 }));
43- list.push_front (new Circle (618 , {7 , 7 }, 7 , " kek" ));
44- list.print_all ();
43+ cout << endl << " ---- id_4 -> [] <- id_3 ----" << endl;
4544
46- cout << endl << " ----------" << endl;
45+ list.push_back (new Segment ({6 , 18 }, {4 , 2 }));
46+ list.push_front (new Circle ({7 , 7 }, 7 , " kek" ));
4747
48- list.get (2 ).print ();
49- cout << " ---------\n " ;
50- list.get (42 ).print ();
48+ list.print_all (); // list now: [id_4, id_2, id_1, id_0, id_3]
5149
52- cout << endl << " ----------del 42----------" << endl;
53- list.erase (42 );
54- list.print_all ();
50+ cout << endl << " ---- [] -> id_3 id_1 ----" << endl;
5551
56- cout << endl << " ----------del 2--------" << endl;
57- list.erase (2 );
58- list.print_all ();
52+ cout << endl; list.get (3 ).print ();
53+ cout << endl; list.get (1 ).print ();
5954
60- cout << endl << " ----------del 618--------" << endl;
61- list.erase (618 );
62- list.print_all ();
55+ cout << endl << " ---- [] -x-> id_4 ----" << endl;
6356
64- cout << endl << " ----------" << endl;
65- list.push_front (new Segment (42 ));
66- list.print_all ();
57+ list.erase (4 );
58+ list.print_all (); // list now: [id_2, id_1, id_0, id_3]
59+
60+ cout << endl << " ---- [] -x-> id_0 ----" << endl;
61+
62+ list.erase (0 );
63+ list.print_all (); // list now: [id_2, id_1, id_3]
64+
65+ cout << endl << " ---- [] -x-> id_3 ----" << endl;
66+
67+ list.erase (3 );
68+ list.print_all (); // list now: [id_2, id_1]
69+
70+ cout << endl << " ---- id_5 -> [] ----" << endl;
71+
72+ list.push_front (new Segment);
73+
74+ list.print_all (); // list now: [id_5, id_2, id_1]
75+
76+ cout << endl << " -------- dop --------" << endl;
77+
78+ cout << endl << " contour id_1: " << list.get (1 ).get_contour_length ();
79+ cout << endl << " contour id_2: " << list.get (2 ).get_contour_length ();
80+ cout << endl << " contour id_5: " << list.get (5 ).get_contour_length ();
81+
82+ cout << endl << endl << " id_1 == id_2: " ;
83+ cout << (list.get (1 ) == list.get (2 ) ? " True" : " False" );
84+
85+ cout << endl << " id_1 == id_5: " ;
86+ cout << (list.get (1 ) == list.get (5 ) ? " True" : " False" );
87+
88+ cout << endl << " id_2 == id_5: " ;
89+ cout << (list.get (2 ) == list.get (5 ) ? " True" : " False" );
90+
91+ // для теста нужно создать одинаковые Circle и Segment (например равные нулю)
92+
93+ cout << endl << endl << " ---- [] <- id_6 ----" << endl;
94+
95+ list.push_back (new Circle); // list now: [id_5, id_2, id_1, id_6]
96+
97+ cout << endl << " contour id_6: " << list.get (6 ).get_contour_length ();
98+
99+ cout << endl << " id_5 == id_6: " ;
100+ cout << (list.get (5 ) == list.get (6 ) ? " True" : " False" ) << endl;
101+
102+ cout << endl << " ------ list_2 ------" << endl;
103+
104+ FigureList list2;
105+ for (double i = 0 ; i < 5 ; i++) {
106+ list2.push_front (new Circle ({0 , 0 }, i));
107+ list2.push_back (new Segment ({0 , 0 }, {i, i}));
108+ }
109+
110+ list2.print_all ();
111+ // list_2 now: [id_15, id_13, id_11, id_9, id_7, id_8, id_10, id_12, id_14, id_16]
67112}
0 commit comments