コード例 #1
0
ファイル: main.cpp プロジェクト: Hadopire/42
int main( void ) {

    // b essaye de signer f mais il est trop noob pour ca
    Bureaucrat b = Bureaucrat("Michel", 20);
    Form f = Form("Traite sur la peche aux moules", 19, 1);
   b.signForm(f);
    // c'est bon la il peut signer youhou
   Form f2 = Form("Traite sur les poneys", 21, 1);
   std::cout << f2 << std::endl;
   std::cout << b << std::endl;
   b.signForm(f2);
    
    // tests de creation de form interdite
   try {

        Form test("lalala", 1, 1000);
    }
    catch (std::exception & e) {
        
        std::cout << e.what() << std::endl;
    }
    try {

        Form test("lalala", 1000, 1);
    }
    catch (std::exception & e) {
        
        std::cout << e.what() << std::endl;
    }
    ShrubberyCreationForm s("test");
    b.signForm(s);
    s.execute(b);
    return (0);
}
コード例 #2
0
ファイル: main.cpp プロジェクト: TheSpoke/piscine_cpp
void					test1(Bureaucrat &b, Form &f)
{
	std::cout << "\033[35mtest1: \033[0m" << std::endl;
	
	std::cout << b.getName() << "(" << b.getGrade() <<
		") trying to sign " << f.getName() << "(" << f.getSGrade() <<
		")" << std::endl;
	b.signForm(f);
	std::cout << std::endl;
	return ;
}
コード例 #3
0
ファイル: main.cpp プロジェクト: DylanLEBLOND/CPP
int		main(void)
{

//Bureaucrat

	Bureaucrat	*a = new Bureaucrat("Akali", 1);
	Bureaucrat  *b = new Bureaucrat("Zed", 50);
	Bureaucrat  *c = new Bureaucrat("Shaco", 150);
	Bureaucrat	*d;
	Bureaucrat	*e;

	try
	{
		d = new Bureaucrat("Dylan", 0);
	}
	catch (std::exception const &err)
	{
		std::cerr << err.what() << std::endl;
		delete d;
	}
	try
	{
		e = new Bureaucrat("Dylan", 151);
	}
	catch (std::exception const &err)
	{
		std::cerr << err.what() << std::endl;
		delete e;
	}

	std::cout << *a << *b << *c;

	b->upgrade();
	std::cout << *b;
	b->downgrade();
	std::cout << *b;

	try
	{
		a->upgrade();
	}
	catch (std::exception const &err)
	{
		std::cerr << err.what() << std::endl;
	}
	std::cout << *a;

	try
    {
        c->downgrade();
    }
    catch (std::exception const &err)
    {
		std::cerr << err.what() << std::endl;
    }
	std::cout << *c;

//Form

	Form *f0 = new Form("Got CPP Piscine", 7, 6);
	Form *f1 = new Form("Beat Math", 3, 3);
	Form *f2 = new Form("Go Eat", 140, 150);
	Form *f3;
	Form *f4;
	Form *f5;
	Form *f6;

	try
    {
		f3 = new Form("Work", 0, 15);
    }
    catch (std::exception const &err)
    {
		std::cerr << err.what() << std::endl;
        delete f3;
    }
    try
    {
        f4 = new Form("Week", 151, 15);
    }
    catch (std::exception const &err)
    {
		std::cerr << err.what() << std::endl;
        delete f4;
    }

	try
	{
		f5 = new Form("Waak", 15, 0);
	}
	catch (std::exception const &err)
	{
		std::cerr << err.what() << std::endl;
		delete f5;
	}
    try
    {
        f6 = new Form("Wuuk", 15, 151);
    }
    catch (std::exception const &err)
    {
		std::cerr << err.what() << std::endl;
        delete f6;
    }
	
	std::cout << *f0 << *f1 << *f2;

	b->signForm(*f0);
	a->signForm(*f1);
	c->signForm(*f2);

	delete a;
	delete b;
	delete c;
	delete f1;
	return 0;
}
コード例 #4
0
ファイル: main.cpp プロジェクト: tlepeche/Piscines
int main(void)
{
	Bureaucrat *Bob = new Bureaucrat("Bob", 2);
	Bureaucrat *Bob2 = new Bureaucrat("John", 142);
	Form *A = new ShrubberyCreationForm("test");
	Form *B = new PresidentialPardonForm("Obama");
	Form *C = new RobotomyRequestForm("Remy");
	srand(time(0));

	try
	{

		Bob->signForm(*A);
		Bob->signForm(*B);
		Bob->signForm(*C);
		Bob->executeForm(*A);
		Bob->executeForm(*B);
		Bob->executeForm(*C);
		Bob->executeForm(*C);
	}
	catch  (std::exception & e)
	{
		std::cout << e.what() << std::endl;
	}

	std::cout << std::endl;

	try
	{
		Bob2->executeForm(*A);

	}
	catch  (std::exception & e)
	{
		std::cout << e.what() << std::endl;
	}

	std::cout << std::endl;

	try
	{
		Bob2->executeForm(*B);
	}
	catch  (std::exception & e)
	{
		std::cout << e.what() << std::endl;
	}

	std::cout << std::endl;

	try
	{
		Bob2->executeForm(*C);
	}
	catch  (std::exception & e)
	{
		std::cout << e.what() << std::endl;
	}

	return 0;
}