1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
#include "Tails.h"
void DanceRight (int[],int);
void DanceLeft (int [], int);
int main ()
{
const int SIZE=9; // Size of the Array
int Pro[SIZE]={1,2,3,4,0,5,6,7,8}; // Starts out the array
bool swap; // End checker
swap=false;
Traffic Slow(Pro,SIZE,swap);
Slow.Declaration(Pro,SIZE);
do
{
DanceRight (Pro,SIZE); //checks if any values can be moved right
DanceLeft (Pro,SIZE); // //checks if any values can be moved left
}
while (!swap); // does while swap isnt true
system("PAUSE");
}
void DanceLeft (int jam[], int SIZE) // sees if values can move left
{
Traffic Slow;
for (int thing=1; thing<SIZE; thing++)
{
if (jam[thing]>4)
// checks to see if value can move right
{
if (jam[thing-2]<5&&jam[thing-1]==0)
// if moving causes the puzzle to get trapped, ends the switches to the other side
{
break;
}
else if (jam[thing-1]==0)
//Moves Right
{
Slow.MoveL (jam,thing);
}
else if (jam[thing-1]<5&&jam[thing-2]==0)
//Jumps Right
{
Slow.JumpL (jam,thing);
}
else
//Any other outcome means I did something wrong
{
cout << "Try again";
system("PAUSE");
}
}
}
}
void DanceRight (int jam[], int SIZE) // sees if values can move Right
{
Traffic Slow;
for (int thing=(SIZE-2); thing>0; thing--)
{
if (jam[thing]<5&&jam[thing]>0)
// checks to see if value can move right
{
if (jam[thing+2]<5&&jam[thing+1]==0)
// if moving causes the puzzle to get trapped, ends the switches to the other side
{
break;
}
else if (jam[thing+1]==0)
//Moves Right
{
Slow.MoveR (jam,thing);
}
else if (jam[thing+1]>4&&jam[thing+2]==0)
//Jumps Right
{
Slow.JumpR (jam,thing);
}
else
//Any other outcome means I did something wrong
{
cout << "Try again";
system("PAUSE");
}
}
}
|