@@ -20,6 +20,7 @@ void Program::start() {
2020 int density;
2121 string matrix;
2222 string list;
23+ char index;
2324
2425 do {
2526 printGraphTypeSelect ();
@@ -96,45 +97,16 @@ void Program::start() {
9697 cout << endl;
9798 break ;
9899
99- case ' 5' : // algorytm 1
100- if (graph->getNumberOfAvailableAlgorithms () > 0 ) {
101- graph->runAlgorithm (1 );
102- } else {
103- cout << " Nie ma takiej opcji, wybierz jeszcze raz." << endl;
104- }
105- break ;
106-
107- case ' 6' : // algorytm 2
108- if (graph->getNumberOfAvailableAlgorithms () > 1 ) {
109- graph->runAlgorithm (2 );
110- } else {
111- cout << " Nie ma takiej opcji, wybierz jeszcze raz." << endl;
112- }
113- break ;
114-
115- case ' 7' : // algorytm 3
116- if (graph->getNumberOfAvailableAlgorithms () > 2 ) {
117- graph->runAlgorithm (3 );
118- } else {
119- cout << " Nie ma takiej opcji, wybierz jeszcze raz." << endl;
120- }
121- break ;
122-
123- case ' 8' : // algorytm 4
124- if (graph->getNumberOfAvailableAlgorithms () > 3 ) {
125- graph->runAlgorithm (4 );
126- } else {
127- cout << " Nie ma takiej opcji, wybierz jeszcze raz." << endl;
128- }
100+ case ' 5' :
101+ graph->test ();
129102 break ;
130103
131- case ' 9' : // algorytm 5
132- if (graph->getNumberOfAvailableAlgorithms () > 4 ) {
133- graph->runAlgorithm (5 );
134- } else {
135- cout << " Nie ma takiej opcji, wybierz jeszcze raz." << endl;
136- }
137- break ;
104+ case ' 6' :
105+ case ' 7' :
106+ case ' 8' :
107+ case ' 9' :
108+ index = option2 - 53 ;
109+ runAlgorithm (index);
138110
139111 case ' 0' :
140112 break ;
@@ -172,10 +144,33 @@ void Program::printGraphMenu() {
172144 cout << " 2. Generuj losowo" << endl;
173145 cout << " 3. Wyswietl graf jako macierz" << endl;
174146 cout << " 4. Wyswietl graf jako lista" << endl;
147+ cout << " 5. Wykonaj testy" << endl;
175148
176149 string availableAlgorithms = graph->getAvailableAlgorithms ();
177150 cout << availableAlgorithms;
178151
179152 cout << " 0. Wyjscie" << endl;
180153 cout << " Podaj opcje:" ;
181154}
155+
156+ void Program::runAlgorithm (char index) {
157+ int arg1;
158+ int arg2;
159+ if (graph->getNumberOfAvailableAlgorithms () > index - 1 ) {
160+ cout<<" Podaj argument 1: " ;
161+ while (!(cin >> arg1)) {
162+ cin.clear ();
163+ cin.ignore (numeric_limits<streamsize>::max (), ' \n ' );
164+ cout << " Bledna wartosc! Podaj argument 1: " ;
165+ }
166+ cout<<" Podaj argument 2: " ;
167+ while (!(cin >> arg2)) {
168+ cin.clear ();
169+ cin.ignore (numeric_limits<streamsize>::max (), ' \n ' );
170+ cout << " Bledna wartosc! Podaj argument 2: " ;
171+ }
172+ graph->runAlgorithm (index, arg1, arg2);
173+ } else {
174+ cout << " Nie ma takiej opcji, wybierz jeszcze raz." << endl;
175+ }
176+ }
0 commit comments