Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Курсовая работа Обмен сообщениями по схеме Клиент-Сервер / TRCLIENT
.CPP#ifndef CPP013
#define CPP013
#include "trclient.h"
trclient::trclient(char N[30])
{
SetName(N);
SetReq(0);
cColTriangle T;
SetColor(T.GetColor());
int i;
for (i=0;i<3;i++)
{
SetTopXY(i,T.GetX(i),T.GetY(i));
};
}
trclient::trclient()
{
char N[30] = "hren";
SetName(N);
SetReq(0);
cColTriangle T;
SetColor(T.GetColor());
int i;
for (i=0;i<3;i++)
{
SetTopXY(i,T.GetX(i),T.GetY(i));
};
}
trclient::trclient(char N[30], cPoint P1, cPoint P2, cPoint P3)
{
SetName(N);
SetReq(0);
cColTriangle T(P1,P2,P3);
SetColor(T.GetColor());
int i;
for (i=0;i<3;i++)
{
SetTopXY(i,T.GetX(i),T.GetY(i));
};
}
void trclient::Set(trclient P)
{
char N[30];
P.GetName(N);
SetName(N);
SetReq(P.getreq());
SetColor(P.GetColor());
int i;
for (i=0;i<3;i++)
{
SetTopXY(i,P.GetX(i),P.GetY(i));
};
}
void trclient::getmsg(msg M)
{
char N[30];
GetName(N);
char a[100];
M.GetAct(a);
if (strcmp(a,"MOVE") == 0)
{
cout<<"Client "<<N<<" incomming command: "<<endl;
cout<<"move("<<M.GetX1()<<";"<<M.GetX2()<<")"<<endl;
Move(M.GetX1(),M.GetX2());
}
else
if (strcmp(a,"ROTATE") == 0)
{
cout<<"Client "<<N<<" incomming command: "<<endl;
cout<<"rotate(("<<M.GetX1()<<";"<<M.GetX2()<<");"<<M.GetX3()<<")"<<endl;
Rotate(M.GetX1(),M.GetX2(),M.GetX3());
}
else
if (strcmp(a,"SCALE") == 0)
{
cout<<"Client "<<N<<" incomming command: "<<endl;
cout<<"scale("<<M.GetX1()<<")"<<endl;
Scale(M.GetX1());
}
else
if ( (strcmp(a,"CHCOLR") == 0)||
(strcmp(a,"CHCOLG") == 0)||
(strcmp(a,"CHCOLB") == 0))
{
cout<<"Client "<<N<<" incomming command: "<<endl;
cout<<"Change color(";
if (strcmp(a,"CHCOLR") == 0)
{
cout<<"RED)"<<endl;
SetColor(red);
}
if (strcmp(a,"CHCOLG") == 0)
{
cout<<"GREEN)"<<endl;
SetColor(green);
}
if (strcmp(a,"CHCOLB") == 0)
{
cout<<"BLUE)"<<endl;
SetColor(blue);
}
}
else
{
cout<<"Client "<<N<<" incomming message: "<<endl;
cout<<a<<endl;
}
SetReq(getreq() + 1);
}
void trclient::out()
{
char N[30];
GetName(N);
cout<<"Client "<<N<<endl;
cout<<"The ";
Colors CurColor;
CurColor = GetColor();
if (CurColor == blue)
cout<<"blue";
else if (CurColor == green)
cout<<"green";
else
cout<<"red";
cout<<" triangle:"<<endl;
int i;
for (i=0;i<3;i++)
GetTop(i).out();
cout<<endl<<endl;
}
trclient::~trclient(){};
#endif
Соседние файлы в папке Курсовая работа Обмен сообщениями по схеме Клиент-Сервер