#include "Vector.h"
#include<stdlib.h>
Vector::Vector()
{
}
Vector::~Vector()
{
}
int* Vector::PosicionTortuga(int v[], int* Punt, int Mov)
{
if (Mov > 0)
{
for (int i = 0; i < Mov; i++)
{
if (Punt == & v[70])
{
return Punt;
}
else
{
Punt++;
}
}
}
if (Mov < 0)
{
for (int i = 0; i > Mov; i--)
{
if (Punt == &v[0])
{
return Punt;
}
else
{
Punt--;
}
}
}
if (Mov==0)
{
Punt = Punt;
}
return Punt;
}
int Vector::MovimientoTortuga()
{
int cant = 0;
int porcentaje = 1 + rand() % (11 - 1);
if (porcentaje <= 5)
{
cant = 3;
}
if (porcentaje <= 7 && porcentaje > 5)
{
cant = -6;
}
if (porcentaje <= 10 && porcentaje > 7)
{
cant = 1;
}
return cant;
}
int Vector::MovimientoConejo()
{
int cant = 0;
int porcentaje = 1 + rand() % (11 - 1);
if (porcentaje >= 9)
{
cant = (0);
}
if (porcentaje >= 7 && porcentaje<9)
{
cant = (9);
}
if (porcentaje == 6)
{
cant = (-12);
}
if (porcentaje >= 3 && porcentaje<6)
{
cant = (1);
}
if (porcentaje >= 1 && porcentaje<3)
{
cant = (-2);
}
return cant;
}
int Vector::PosicionImpresion(int v[], int* P)
{
int* PVec = &v[0];
int Pos = 0;
while (PVec<P)
{
PVec++;
Pos++;
}
return Pos;
}
System::String^ Vector::Impresion(int* PConejo,int*PTortuga,int Vec[])
{
int Conejo = PosicionImpresion(Vec , PConejo);
int Tortuga = PosicionImpresion(Vec , PTortuga);
System::String^Res = "";
int Tam = 70;
return (Recusivo(Res, Tortuga, Conejo, Tam));
}
System::String^ Vector::Recusivo(System::String^Res, int T, int C, int Tam)
{
if (Tam == -1)
{
return Res;
}
else
{
if (T == C && T == Tam)
{
Res += Recusivo(Res, T, C, Tam - 1) + "Ouch";
return Res;
}
if (C == Tam)
{
return Res += Recusivo(Res, T, C, Tam - 1) + "H";
}
if (T == Tam)
{
return Res += Recusivo(Res, T, C, Tam - 1) + "T";
}
else
{
return Res += Recusivo(Res, T, C, Tam - 1) + ".";
}
}
}