Exemple #1
0
int	main(void)
{
	CentralBureaucracy	cb;
	Bureaucrat			*b[40];
	int lvl = 122;
	for (int i = 0; i < 40; ++i)
	{
		std::stringstream ss;
		ss << "b" << i;
		b[i] = new Bureaucrat(ss.str(), lvl);
		lvl -= 3;
		cb.feed(*b[i]);
	}
	std::string forms[3] = {"presidential pardon", "robotomy request", "shrubbery creation"};
	for (int i = 0; i < 100; ++i)
	{
		std::stringstream target;
		target << "Target " << i;
		cb.queueUp(forms[i % 3], target.str());
	}
	cb.doBureaucracy();
	// Intern	someRandomIntern;
	// Bureaucrat	b1("Bob", 60);
	// Bureaucrat	b2("Fred", 1);
	// Bureaucrat	b3("Minister", 10);
	// OfficeBlock	block(someRandomIntern, b1, b2);
	// bool	is_exec = false;
	// try
	// {
	// 	block.doBureaucracy("presidential pardon", "Me");
	// 	is_exec = true;
	// }
	// catch (Form::GradeTooLowException& e) {
	// 	std::cerr << "Grade is too low to sign or execute form \"presidential pardon\"" << std::endl;
	// }
	// catch (std::exception& e) {
	// 	std::cerr << "Unknow exception: " << e.what() << std::endl;
	// }
	// if (!is_exec) {
	// 	try
	// 	{
	// 		block.setSigner(b3);
	// 		block.doBureaucracy("presidential pardon", "Me");
	// 		is_exec = true;
	// 	}
	// 	catch (Form::GradeTooLowException& e) {
	// 		std::cerr << "Grade is too low to sign or execute form \"presidential pardon\"" << std::endl;
	// 	}
	// 	catch (std::exception& e) {
	// 		std::cerr << "Unknow exception: " << e.what() << std::endl;
	// 	}
	// }
	// if (is_exec)
	// 	std::cout << "The form has been executed" << std::endl;
	// else
	// 	std::cout << "The form has'nt been executed" << std::endl;
	return (0);
}
Exemple #2
0
int main(void) {
	CentralBureaucracy		central;

	for (int i = 0; i < 20; i++) {
		std::string str1 = "Bureaucrat1:" + itoa(i);
		central.feedOffice(*new Bureaucrat("Bureaucrat1:" + itoa(i), 1), i);
		if (rand() % 2 == 0)
			central.feedOffice(*new Bureaucrat("Bureaucrat2:" + itoa(i), 1), i);
	}

	central.queueUp("presidential pardon");
	central.queueUp("robotomy request");
	central.queueUp("shrubbery creation");
	central.queueUp("robotomy request");
	central.queueUp("presidential pardon");
	central.queueUp("robotomy request");
	central.queueUp("shrubbery creation");
	central.queueUp("robotomy request");
	central.queueUp("robotomy request");
	central.queueUp("robotomy request");
	central.queueUp("presidential pardon");
	central.queueUp("presidential pardon");
	central.queueUp("robotomy request");
	central.queueUp("shrubbery creation");
	central.queueUp("robotomy request");
	central.queueUp("robotomy request");
	central.queueUp("robotomy request");

	central.doBureaucracy();
	return (0);
}