Скачиваний:
8
Добавлен:
01.05.2014
Размер:
5.65 Кб
Скачать
#include <conio.h>
#include <math.h>
#include <iostream.h>
#include <fstream.h>
#include "list1.cpp"
#include <values.h>
#include <stdlib.h>

void main()
{
 double x=0.0,y=1.0,Ch1,Ch2,Ch3;

 int j=0;
 cout.precision(5);

 cColTriangle P;
 List L;
 double Sq;
// List2 L1,L2;

 int i,exit=0,ex = 0,C,C1,D;

while (!ex)
{
clrscr();

if (!L.Empty())
{
L.GetInf(P);

	 cout << "The current position is:" <<endl;
	 for (i=0;i<3;i++)
	 {
		x=P.GetX(i);
		y=P.GetY(i);
		cout<<"("<<x<<","<<y<<")   ";
	 };
}
else
 cout<<"The List is empty now";
cout <<endl<<endl<<endl

		 <<"1. Change current triangle"<<endl<<endl
		 <<"2. add a triangle."<<endl
		 <<"3. delete current triangle"<<endl
		 <<"4. go to the next triangle"<<endl
		 <<"5. print the list"<<endl/*<<endl
		 <<"6. cut the list"<<endl
		 <<"7. print double-directet lists"<<endl
		 */<<"6. exit"<<endl
		 <<endl<<endl
		 <<"input your choice: ";

cin >> C1;



if (C1==1)
{
j=1;
exit = 0;
L.GetCur(P);
while (!exit)
 {
	Sq=P.Square();
	C = 0;
	while ((C<1)||(C>5))
	{
	 clrscr();
	 cout << "The current position is:" <<endl;
	 for (i=0;i<3;i++)
	 {
		x=P.GetX(i);
		y=P.GetY(i);
		cout<<"("<<x<<","<<y<<")   ";
	 };
	 cout<<endl<<"The square is: "<<Sq;
	 cout <<endl<<endl<<endl;


	 cout<<endl<<"1. New coordinates"
			 <<endl<<"2. Move triangle"
			 <<endl<<"3. Rotate triangle"
			 <<endl<<"4. Scale triangle"
			 <<endl<<"5. Exit"
			 <<endl<<endl<<endl<<endl
			 <<"Enter your choice: ";

	 cin>>C;
	};

	Ch1 = -1;
	Ch2 = -1;
	Ch3 = -1;

	if (C==1)
	{

	 while (!((Ch3==4)&&(P.rb())&&(P.correct())))
	 {

		clrscr();
		cout << "The current position is:" <<endl;
		for (i=0;i<3;i++)
		{
		 x=P.GetX(i);
		 y=P.GetY(i);
		 cout<<"("<<x<<","<<y<<")   ";
		};
		if (!((P.rb())&&(P.correct()))) cout <<"in";
		cout<<"correct triangle";
		cout <<endl<<endl<<endl;


		cout<<endl<<"1. Move the first point"
				<<endl<<"2. Move the second point"
				<<endl<<"3. Move the third point"
				<<endl<<"4. Exit if the figure is correct"
				<<endl<<endl<<endl<<endl
				<<"   Enter your choice: ";




		cin>>Ch3;



	 if (Ch3 != 4)
		{
		 clrscr();
		 cout <<endl<<endl<<endl<< "New x coordinate: ";
		 cin >> Ch1;
		 cout<<endl<<"New y coordinate: ";
		 cin>>Ch2;
		 P.SetTopXY(Ch3-1,Ch1,Ch2);
		};

	 };
	};


	if (C==2)
	{
		clrscr();

		cout << "The current position is:" <<endl;
		for (i=0;i<3;i++)
		{
		 x=P.GetX(i);
		 y=P.GetY(i);
		 cout<<"("<<x<<","<<y<<")   ";
		};
		cout<<endl<<endl<<endl<<"input a horizontal change: ";
		cin>>Ch1;


		cout<<endl<<"input a vertical change: ";
		cin>>Ch2;

	 clrscr();
	 P.Move(Ch1,Ch2);
	};

	if (C==3)
	{
		clrscr();
		cout << "The current position is:" <<endl;
		for (i=0;i<3;i++)
		{
		 x=P.GetX(i);
		 y=P.GetY(i);
		 cout<<"("<<x<<","<<y<<")   ";
		};

		cout<<endl<<endl<<endl<<"input the the rotation center: "<<endl<<endl<<"the first coordinate: ";

		cin>>Ch1;

		cout<<"the second coordinate: ";
		cin>>Ch2;


		D=0;
		while ((D<1)||(D>3))
		{
		 clrscr();
		 cout<<"input the rotation angle: "<<endl<<endl<<endl;
		 cout<<endl<<"  1. radians"
	 <<endl<<"  2. degrees"
	 <<endl<<"  3. parts of Pi"
	 <<endl<<endl<<endl<<endl
	 <<"Enter your choice: ";


		 cin >> D;
		};

			cout<<endl<<endl<<endl<<"The angle: " ;
			cin>>Ch3;

		 if (D==2) Ch3*=M_PI/180;
		 if (D==3) Ch3*=M_PI;


		clrscr();
		P.Rotate(Ch1,Ch2,Ch3);
	};


	if (C==4)
	{


		while (Ch1<=0)
		{
		clrscr();
		cout << "The current position is:" <<endl;
		for (i=0;i<3;i++)
		{
		 x=P.GetX(i);
		y=P.GetY(i);
		 cout<<"("<<x<<","<<y<<")   ";
		};

		cout<<endl<<endl<<"input a scale coefficient: ";
		cin>>Ch1;
		}


	 clrscr();
	 P.Scale(Ch1);
	};

	if (C==5)
	 exit = 1;

};
L.add(P);

 }





if (C1==2)
{
 j=1;
 Ch3=-1;

 P.SetTopXY(0,0.0,0.0);
 P.SetTopXY(1,1.0,0.0);
 P.SetTopXY(2,0.0,1.0);

 while (!((Ch3==5)&&(P.rb())&&(P.correct())))
	 {

		clrscr();
		cout << "The current position is:" <<endl;
		for (i=0;i<3;i++)
		{
		 x=P.GetX(i);
		 y=P.GetY(i);
		 cout<<"("<<x<<","<<y<<")   ";
		};
		if (!((P.rb())&&(P.correct()))) cout <<"in";
		cout<<"correct triangle";
		cout <<endl<<endl<<endl;


		cout<<endl<<"1. Move the first point"
				<<endl<<"2. Move the second point"
				<<endl<<"3. Move the third point"
				<<endl<<"4. Scale if the figure is correct"
				<<endl<<"5. Exit if the figure is correct"
				<<endl<<endl<<endl<<endl
				<<"   Enter your choice: ";




		cin>>Ch3;



	 if (Ch3 < 4)
		{
		 clrscr();
		 cout <<endl<<endl<<endl<< "New x coordinate: ";
		 cin >> Ch1;
		 cout<<endl<<"New y coordinate: ";
		 cin>>Ch2;
		 P.SetTopXY(Ch3-1,Ch1,Ch2);
		};


	 if (Ch3 == 4)
	  {
	   Ch1 = -1;
	   while (Ch1<=0)
	   {
	    clrscr();
	    cout <<endl<<endl<<endl<< "Input a coefficient: ";
	    cin >> Ch1;
	   };
	   P.Scale(Ch1);
	  }

	 };

 L.add(P);
 clrscr();
 cout<<"The triangle has been added";
 getch();
};



if (C1==3)
{
 j=1;
 L.del();
 clrscr();
 cout<<"The triangle has been deleted";
 getch();
};

if (C1==4)
{
 L.move();
};

if (C1==5)
{
 L.out();
 getch();
}

/*
if (C1==6)
{
j=0;
clrscr();
L.div(L1,L2);
cout<<"The list has been cut";
getch();
}

if (C1==7)
{
 clrscr();
 if (!j)
 {
  cout<<"The first:"<<endl;
  L1.out();
  cout<<endl<<endl
      <<"The second:"<<endl;
  L2.out();
 }
 else
  cout<<"The list first should be cut";
 getch();

}*/

if (C1==6)
 ex = 1;
}
}
Соседние файлы в папке Лабораторная работа 32