Ejemplo n.º 1
0
int main(){
	int x=0;
	int y=0;
	int a=0;
	tabla();
	do{
		printf("\n\t\t\t\t\tAJEDREZ\n");
		if(y==1)
		printf("\t\t\t\tMOVIMIENTO INVALIDO\n");
		pantalla();
		a=menu();
		tabla();
		printf("\n\tx: ");
		scanf("%d",&x);

		printf("\ty: ");
		scanf("%d",&y);

		switch(a){
			case 1:torre	(x,y);break;
			case 2:reyna	(x,y);break;
			case 3:arfil	(x,y);break;
			case 4:y=peon	(x,y);break;
			case 5:caballo	(x,y);break;
			case 6:rey	(x,y);break;
		}
		system("cls");
	}while(a<7);
}
Ejemplo n.º 2
0
int main(void)
{
	int			grades[] = { 1, 150, 0, 160, 100};
	std::string	names[] = { "Gui", "Pe", "Fran", "Bra", "Ju" };
	std::string	forms[] = {  "Form1", "Form2", "Form3", "Form4", "Form5", };

	Bureaucrat peon("Henri", 145);
	Bureaucrat chief("Jack", 1);

	for (int i = 0; i < 5; i++)
	{
		std::cout << "------------- Test " << i << std::endl;
		try
		{
			Form form(forms[i], grades[i], 120);
			std::cout << form << std::endl;
			chief.signForm(form);
			peon.signForm(form);
			std::cout << form << std::endl;
		}
		catch (std::exception & e)
		{
			std::cout << e.what() << std::endl;
		}
	}

	std::cout << std::endl;

	for (int i = 0; i < 5; i++)
	{
		try
		{
			Bureaucrat b(names[i], grades[i]);
			std::cout << b << std::endl;
			std::cout << "increase : ";
			b.increaseGrade();
			std::cout << b << std::endl;
			std::cout << "decrease : ";
			b.decreaseGrade();
			std::cout << b << std::endl;
			std::cout << "decrease : ";
			b.decreaseGrade();
			std::cout << b << std::endl;
		}
		catch (std::exception & e)
		{
			std::cout << "Grade " << grades[i] << " "  << e.what() << std::endl;
		}
	}
	return (0);
}
Ejemplo n.º 3
0
		int main(int argc, char * argv[]){
			system("clear");
			system("toilet AJEDREZ");

			int mapa[DIM][DIM]={		//declaramos un array bidimensional de ints

				{1,0,1,0,0,1,1,0},
				{1,0,0,1,1,0,0,0},
				{0,1,1,1,0,1,0,0},
				{1,0,1,0,0,1,0,0},
				{0,1,0,1,0,1,0,0},
				{1,0,1,0,0,0,0,0},
				{1,0,1,0,0,0,0,0},
				{1,0,1,0,0,0,0,0},

			};

			int posicionx;
			int posiciony;
			int pieza;

			printf("Que pieza quieres usar:\n \n\t1 Caballo\n \t2 Peon\n \t3 Rey\n\n");

			scanf("%i", &pieza);

			printf("Dime la posicion x de la pieza \n");

			scanf("%i", &posicionx);

			printf("Dime la posicion y de la pieza \n");

			scanf("%i", &posiciony);


			switch(pieza)		//con este switch llamaremos a la funcion que necesitemos
			{
				case 1:
				pieza=1;
				caballo(mapa, posicionx, posiciony);
				break;

				case 2:
				pieza=2;
				peon(mapa, posicionx, posiciony);
				break;

				case 3:
				pieza=3;
				rey(mapa, posicionx, posiciony);
				break;

				default:
				printf("No elegiste un pieza disponible\n");
				break;
			};





			return EXIT_SUCCESS;
		}
Ejemplo n.º 4
0
int main(void)
{
	Bureaucrat peon("Henri", 145);
	Bureaucrat chief("Jack", 1);

	std::cout << "Shrubbery form" << std::endl;
	Form *form = new ShrubberyForm("Home");
	try
	{
		std::cout << *form << std::endl;
		chief.signForm(*form);
		peon.signForm(*form);
		std::cout << *form << std::endl;
		chief.executeForm(*form);
		peon.executeForm(*form);
	}
	catch (std::exception & e)
	{
		std::cout << e.what() << std::endl;
	}
	delete form;

	std::cout << std::endl << "Shrubbery form" << std::endl;
	Form *form0 = new ShrubberyForm("Home");
	try
	{
		std::cout << *form0 << std::endl;
		chief.executeForm(*form0);
	}
	catch (std::exception & e)
	{
		std::cout << e.what() << std::endl;
	}
	delete form0;

	std::cout << std::endl << "Robotomy form" << std::endl;
	Form *form1 = new RobotomyForm("Arthur Dent");
	try
	{
		std::cout << *form1 << std::endl;
		chief.signForm(*form1);
		std::cout << *form1 << std::endl;
		chief.executeForm(*form1);
	}
	catch (std::exception & e)
	{
		std::cout << e.what() << std::endl;
	}
	delete form1;

	std::cout << std::endl << "Presidential Pardon form" << std::endl;
	Form *form2 = new PresidentialPardonForm("Ford Prefect");
	try
	{
		std::cout << *form2 << std::endl;
		chief.signForm(*form2);
		std::cout << *form2 << std::endl;
		chief.executeForm(*form2);
		peon.executeForm(*form2);
	}
	catch (std::exception & e)
	{
		std::cout << e.what() << std::endl;
	}
	delete form2;

	return (0);
}