Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------
- #include <iostream.h>
- #include <vcl.h>
- #include <string.h>
- #pragma hdrstop
- //---------------------------------------------------------------------------
- #pragma argsused
- class point{
- private:
- int x, y;
- public:
- point(int xi, int yi): x(xi), y(yi){}
- point(): x(0), y(0){}
- void set_x(int fx)
- {
- x = fx;
- }
- void set_y(int fy)
- {
- y = fy;
- }
- void inc_x()
- {
- x++;
- }
- void inc_y()
- {
- y++;
- }
- void dec_y()
- {
- y--;
- }
- void dec_x()
- {
- x--;
- }
- int ret_x(){
- return x;
- }
- int ret_y(){
- return y;
- }
- void ret_cord(){
- cout << "(" << x << "; " << y << ")" << endl;
- }
- void addPoint(point &dt){
- x += dt.x;
- y += dt.y;
- dt.y = y;
- dt.x = x;
- }
- void subPoint(point &dt){
- x -= dt.x;
- y -= dt.y;
- dt.y = y;
- dt.x = x;
- }
- void mulPoint(point &dt){
- x *= dt.x;
- y *= dt.y;
- dt.y = y;
- dt.x = x;
- }
- void divPoint(point &dt){
- if(dt.x!=0)
- x /= dt.x;
- if(dt.y!=0)
- y /= dt.y;
- dt.y = y;
- dt.x = x;
- }
- };
- class parceCord{
- private:
- std::string raw, buffer, buffer1, command;
- unsigned int i;
- int xData, yData;
- public:
- parceCord(): i(0), raw(""), buffer(""), xData(0), yData(0){}
- void parceInp(std::string str){
- raw = str;
- }
- void parceS(std::string str){
- buffer = str;
- if(str == "")
- buffer = raw;
- i = 0;
- buffer1 = "";
- while(i < buffer.length()){
- while(buffer[i] == ' ')
- buffer.erase(i, 1);
- i++;
- }
- //cout << buffer << endl;
- buffer = buffer1;
- i = 0;
- buffer1 = "";
- while(buffer[i] != '('){
- buffer1 += buffer[i];
- i++;
- }
- i++;
- command = buffer1;
- buffer1 = "";
- while(buffer[i] != ';'){
- buffer1 += buffer[i];
- i++;
- }
- i++;
- xData = atoi(buffer1.c_str());
- buffer1 = "";
- while(buffer[i] != ')'){
- buffer1 += buffer[i];
- i++;
- }
- yData = atoi(buffer1.c_str());
- buffer1 = "";
- buffer = "";
- }
- void retRaw(std::string &ret){
- ret = raw;
- }
- std::string retComm(){
- return command;
- }
- void retXdata(int &x){
- x = xData;
- }
- void retYdata(int &y){
- y = yData;
- }
- void retCord(point &ret){
- ret.set_x(xData);
- ret.set_y(yData);
- }
- };
- class doCommands{
- private:
- public:
- void process(std::string command, point &dot, point argum){
- if(command == "set"){
- dot.set_x(argum.ret_x());
- dot.set_y(argum.ret_y());
- }
- }
- };
- int main(int argc, char* argv[])
- {
- std::string inp;
- cin >> inp;
- parceCord parcer;
- parcer.parceS(inp);
- point argum;
- parcer.retCord(argum);
- argum.ret_cord();
- point dot1(0, 0);
- doCommands commander;
- commander.process(parcer.retComm(), dot1, argum);
- dot1.ret_cord();
- system("pause");
- return 0;
- }
- //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement