Code:
#include <iostream>
#include "one.h"
#include "two.h"
#include "three.h"
#include "four.h"
#include "five.h"
#include "six.h"
using namespace std;
void test(int &value_1,
int &value_2,
int x,
int &check_case_1_value_2,
int &check_case_4_value_2,
int &case_that_closed_loop,
int &case_0_true,
int &loop_from_case_1_to_case_4,
int &loop_from_case_4_to_case_1,
int &case_2_loop_not_finished,
int &case_5_loop_not_finished,
int page,
int &old_case_2_page,
int &old_case_5_page,
int &save_page_case_2,
int &save_page_case_5,
int &while_true,
int &loop_from_case_2_to_case_4,
int &case_2_repeat_value,
int &case_5_repeat_value,
float &average_for_case_2_test,
float &average_for_case_5_test,
int &test_for_case_2_go_to_break,
int &test_for_case_5_go_to_break)
{
int value_3[6] = { 0, 0, 0, 0, 0, 0 };
int value_4[6] = { 0, 0, 0, 0, 0, 0 };
// if weight out between 1 and 5
one obj1 {value_3[0]};
// if added weight out between 1 and 0
two obj2 {obj1.get_data_value(),
value_3[1],
value_4[1]};
// if weight is continued to goal weight starting from previous last weight
three obj3 {obj1.get_data_value(),
obj2.get_data_value(),
obj2.get_second_data_value(),
value_3[2],
value_4[2]};
// if weight in between weight out and 1
four obj4 {obj1.get_data_value(),
obj2.get_data_value(),
obj2.get_second_data_value(),
obj3.get_data_value(),
obj3.get_second_data_value(),
value_3[3]};
// if added weight out between 1 and 0
five obj5 {obj1.get_data_value(),
obj2.get_data_value(),
obj2.get_second_data_value(),
obj3.get_data_value(),
obj3.get_second_data_value(),
obj4.get_data_value(),
value_3[4],
value_4[4]};
// if weight is continued to goal weight starting from previous last weight
six obj6 {obj1.get_data_value(),
obj2.get_data_value(),
obj2.get_second_data_value(),
obj3.get_data_value(),
obj3.get_second_data_value(),
obj4.get_data_value(),
obj5.get_data_value(),
obj5.get_second_data_value(),
value_3[5],
value_4[5]};
switch(x)
{
case 0 :
obj1.switch_zero(value_1);
if(case_0_true == 1) // go right
{
value_1 = 1;
}
else if(value_1 == 0) // go left
{
case_that_closed_loop = 0;
while_true = 0;
}
break;
case 1 :
obj2.switch_zero(value_1, value_2);
if(value_2 == 1) // left then right
{
// add to for loop as condition,
// so that if loop stops somewhere between case 1 and case 4, case 1 continues loop to case 4.
// loop from case 1 to case 4
loop_from_case_1_to_case_4 = 1;
//loop returns to this case on different page
if(case_2_loop_not_finished == 1)
{
check_case_1_value_2 += 1; // too much makes a high percentage which is a bad sign
}
}
else if(value_2 == 0) // left then left
{
case_that_closed_loop = 1;
while_true = 0;
}
break;
case 2 :
obj3.switch_zero(value_1, value_2);
if(value_1 == 1)
{
// on next loop increment loop in this case
// next loop counts check_case_1_value_2 value.
// test if check_case_1_value_2 value is a high percentage of this cases repeated loop value.
// if previous case value_2 == 1 for n number of repeated loops = high percentage
// then case 1 is aware of case 2.
cout << "are you finished this loop? 1 = yes, 0 = no: ";
cin >> case_2_loop_not_finished;
if(case_2_loop_not_finished == 0) // finished
{
old_case_2_page = page; // page is refreshed
save_page_case_2 = 0;
// test to see if the previous case is aware of this case
average_for_case_2_test = check_case_1_value_2 / case_2_repeat_value;
if(average_for_case_2_test > 0.3)
{
loop_from_case_1_to_case_4 = 0;
// break to end program, add condition to for loop to end program
test_for_case_2_go_to_break = 1;
}
}
else if( (case_2_loop_not_finished == 1) && (save_page_case_2 == 0) ) // not finished
{
old_case_2_page = page; // page is saved
save_page_case_2 = 1;
case_2_repeat_value++;
}
else
{
case_2_repeat_value++;
}
}
if(value_2 == 0)
{
loop_from_case_2_to_case_4 = 1;
}
break;
case 3 :
obj4.switch_zero(value_1);
if(value_1 == 0)
{
// closes previous case which stops case 2 from completing its loop.
// if case 1 is going to case 4
// if case 2 testing case 1 had a high percentage, then prevent case 1 from going to case 4
case_that_closed_loop = 3;
while_true = 0;
}
break;
case 4 :
obj5.switch_zero(value_1, value_2);
if(value_2 == 1) // left then right
{
// add to for loop as condition,
// so that if loop stops somewhere between case 1 and case 4, case 1 continues loop to case 4.
// loop from case 1 to case 4
loop_from_case_4_to_case_1 = 1;
//loop returns to this case on different page
if( case_5_loop_not_finished == 1)
{
check_case_4_value_2 += 1; // too much makes a high percentage which is a bad sign
}
}
else if(value_2 == 0) // left then left
{
case_that_closed_loop = 4;
while_true = 0;
}
break;
case 5 :
obj6.switch_zero(value_1, value_2);
if(value_1 == 1)
{
// stay in case position to finish incrementing loop while also continuing on to next case
// then go to previous case and test if value_2 == 1 for n number of repeated loops in case 2.
// if previous case value_2 == 1 for n number of repeated loops = high percentage
// then case 4 is aware of case 5.
// if case 4 aware of case 5, then case 5 true = true, even if its true becomes false.
// else if case 5 true becomes false, go to case 0 true
cout << "are you finished this loop? 1 = yes, 0 = no: ";
cin >> case_5_loop_not_finished;
if(case_5_loop_not_finished == 0) // finished
{
old_case_5_page = page; // page is refreshed
save_page_case_5 = 0;
// test to see if the previous case is aware of this case
average_for_case_5_test = check_case_4_value_2 / case_5_repeat_value;
if(average_for_case_5_test > 0.3)
{
loop_from_case_4_to_case_1 = 0;
// break to end program, add condition to for loop to end program
test_for_case_5_go_to_break = 1;
}
}
else if( (case_5_loop_not_finished == 1) && (save_page_case_5 == 0) ) // not finished
{
old_case_5_page = page; // page is saved
save_page_case_5 = 1;
case_5_repeat_value++;
}
else
{
case_5_repeat_value++;
}
}
break;
}
}
int main() {
int check_case_1_value_2 = 0;
int check_case_4_value_2 = 0;
int case_that_closed_loop = 0;
int case_0_true = 0;
int loop_from_case_1_to_case_4 = 0;
int loop_from_case_4_to_case_1 = 0;
int case_2_loop_not_finished = 0;
int case_5_loop_not_finished = 0;
int page = 0;
int old_case_2_page = 0;
int old_case_5_page = 0;
int save_page_case_2 = 0;
int save_page_case_5 = 0;
int while_true = 1;
int loop_from_case_2_to_case_4 = 0;
int case_2_repeat_value = 0;
int case_5_repeat_value = 0;
float average_for_case_2_test = 0;
float average_for_case_5_test = 0;
int test_for_case_2_go_to_break = 0;
int test_for_case_5_go_to_break = 0;
int value_1[6] = { 0, 0, 0, 0, 0, 0 };
int value_2[6] = { 0, 0, 0, 0, 0, 0 };
// if weight out between 1 and 5
one obj1 {value_1[0]};
// if added weight out between 1 and 0
two obj2 {obj1.get_data_value(),
value_1[1],
value_2[1]};
// if weight is continued to goal weight starting from previous last weight
three obj3 {obj1.get_data_value(),
obj2.get_data_value(),
obj2.get_second_data_value(),
value_1[2],
value_2[2]};
// if weight in between weight out and 1
four obj4 {obj1.get_data_value(),
obj2.get_data_value(),
obj2.get_second_data_value(),
obj3.get_data_value(),
obj3.get_second_data_value(),
value_1[3]};
// if added weight out between 1 and 0
five obj5 {obj1.get_data_value(),
obj2.get_data_value(),
obj2.get_second_data_value(),
obj3.get_data_value(),
obj3.get_second_data_value(),
obj4.get_data_value(),
value_1[4],
value_2[4]};
// if weight is continued to goal weight starting from previous last weight
six obj6 {obj1.get_data_value(),
obj2.get_data_value(),
obj2.get_second_data_value(),
obj3.get_data_value(),
obj3.get_second_data_value(),
obj4.get_data_value(),
obj5.get_data_value(),
obj5.get_second_data_value(),
value_1[5],
value_2[5]};
while (while_true)
{
for (int x = 0; x < 6; ++x) {
test(value_1[x],
value_2[x],
x,
check_case_1_value_2,
check_case_4_value_2,
case_that_closed_loop,
case_0_true,
loop_from_case_1_to_case_4,
loop_from_case_4_to_case_1,
case_2_loop_not_finished,
case_5_loop_not_finished,
page,
old_case_2_page,
old_case_5_page,
save_page_case_2,
save_page_case_5,
while_true,
loop_from_case_2_to_case_4,
case_2_repeat_value,
case_5_repeat_value,
average_for_case_2_test,
average_for_case_5_test,
test_for_case_2_go_to_break,
test_for_case_5_go_to_break);
if( (test_for_case_2_go_to_break) || (test_for_case_5_go_to_break) )
{
while_true = 0;
break;
}
if ( ((x == 0) && (value_1[0] == 1)) || (loop_from_case_4_to_case_1) ) {
// if weight out between 1 and 5
} else if ((x == 1) && ((value_1[1] == 1) || (value_2[1] == 1)) && (value_1[0] == 1)) //
{
// if added weight out between 1 and 0
} else if ( ((x == 2) && ((value_1[1] == 1) || (value_2[1] == 1))) || (loop_from_case_1_to_case_4) ) {
// if weight is continued to goal weight starting from previous last weight
} else if ( ((x == 3) && (value_1[3] == 1)) || (loop_from_case_1_to_case_4) ) {
// if weight in between weight out and 1
} else if ((x == 4) && ((value_1[4] == 1) || (value_2[4] == 1)) && (value_1[3] == 1)) {
// if added weight out between 1 and 0
} else if ( ((x == 5) && ((value_1[4] == 1) || (value_2[4] == 1))) || (loop_from_case_4_to_case_1) ) {
// if weight is continued to goal weight starting from previous last weight
} else {
cout << "\nexit program\n\n";
break;
}
}
page++;
}
return 0;
}