2828int main () {
2929 FigureList list;
3030
31- Circle *c_1 = new Circle (42 , {0 , 0 }, 1 , " lol kek" );
32- Circle *c_2 = new Circle (24 , {4 , 2 }, 7 , " cheburek" );
33- Segment *s_1 = new Segment (1 , {0 , 0 }, {42 , 42 });
31+ cout << endl << " ---- id_2 id_1 id_0 -> [] ----" << endl;
3432
35- list. push_front (c_1 );
36- list. push_front (c_2 );
37- 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 } );
3836
39- list.print_all ();
37+ list.push_front (c1);
38+ list.push_front (c2);
39+ list.push_front (s1);
4040
41- cout << endl << " ---------- " << endl;
41+ list. print_all (); // list now: [id_2, id_1, id_0]
4242
43- list.push_back (new Segment (2 , {6 , 18 }, {4 , 2 }));
44- list.push_front (new Circle (618 , {7 , 7 }, 7 , " kek" ));
45- list.print_all ();
43+ cout << endl << " ---- id_4 -> [] <- id_3 ----" << endl;
4644
47- cout << endl << " ----------" << endl;
45+ list.push_back (new Segment ({6 , 18 }, {4 , 2 }));
46+ list.push_front (new Circle ({7 , 7 }, 7 , " kek" ));
4847
49- list.get (2 ).print ();
50- cout << " ---------\n " ;
51- list.get (42 ).print ();
48+ list.print_all (); // list now: [id_4, id_2, id_1, id_0, id_3]
5249
53- cout << endl << " ----------del 42----------" << endl;
54- list.erase (42 );
55- list.print_all ();
50+ cout << endl << " ---- [] -> id_3 id_1 ----" << endl;
5651
57- cout << endl << " ----------del 2--------" << endl;
58- list.erase (2 );
59- list.print_all ();
52+ cout << endl; list.get (3 ).print ();
53+ cout << endl; list.get (1 ).print ();
6054
61- cout << endl << " ----------del 618--------" << endl;
62- list.erase (618 );
63- list.print_all ();
55+ cout << endl << " ---- [] -x-> id_4 ----" << endl;
6456
65- cout << endl << " ----------" << endl;
66- list.push_front (new Segment (42 ));
67- list.print_all ();
57+ list.erase (4 );
58+ list.print_all (); // list now: [id_2, id_1, id_0, id_3]
6859
69- cout << endl << " ---------- dop ------ ----" << endl;
60+ cout << endl << " ---- [] -x-> id_0 ----" << endl;
7061
71- cout << endl << " id_42 == id_24: "
72- << (list.get (42 ) == list.get (24 ) ? " True" : " False" )
73- << endl;
62+ list.erase (0 );
63+ list.print_all (); // list now: [id_2, id_1, id_3]
7464
75- cout << " contour id24: " << list.get (24 ).get_contour_length () << endl;
76- cout << " contour id42: " << list.get (42 ).get_contour_length () << endl;
65+ cout << endl << " ---- [] -x-> id_3 ----" << endl;
7766
78- // для теста нужно создать одинаковые Circle и Segment
67+ list.erase (3 );
68+ list.print_all (); // list now: [id_2, id_1]
7969
80- list.push_front (new Circle (123 , {0 , 0 }, 0 , " нет слов, одни эмоции" ));
81- list.push_front (new Segment (321 , {0 , 0 }, {0 , 0 }));
70+ cout << endl << " ---- id_5 -> [] ----" << endl;
8271
83- cout << " id_123 == id_321: "
84- << (list.get (123 ) == list.get (321 ) ? " True" : " False" )
85- << endl;
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]
86112}
0 commit comments