Exemplo n.º 1
0
Arquivo: main.cpp Projeto: CCJY/coliru
int main()
{
   employee paul("Paul","Economics");
   person  john( "Mumu");
   somefunc(paul);
   somefunc(john);
}
Exemplo n.º 2
0
int main()
{
	Employee joe("Joe", "Butcher");
	Friend john("John");
	std::vector<Person> people;
	people.push_back(joe);
	people.push_back(john);

	int n = people.size();

	for (int i = 0; i < n; i++) {
		people[i].Print();
	}


	// design flaw is that it will call upon the Base::Function() as opposed to the Derived::Function()

	
}
Exemplo n.º 3
0
int main()
{
    Person jane("Jane Doe", 37, 64, 115, true);
    Person john("John Smith", 87, 70, 180, false);

    Person noone;
    // Can't touch these values; they're private.  Uncomment these lines
    // to see the compiler messages.
    //strcpy(noone.name, "Davy Jones");
    //noone.age = 99;
    // Check the output again, with the new default constructor

    char ident[1000];

    jane.tostring(ident);
    printf("Jane ==> %s\n", ident);
    john.tostring(ident);
    printf("John ==> %s\n", ident);
    noone.tostring(ident);
    printf("noone==> %s\n", ident);

    return 0;
}
Exemplo n.º 4
0
int main()
{
    Person jane("Jane Doe", 37, 64, 115, true);
    Person john("John Smith", 87, 70, 180, false);

    // Now we can use the default constructor and initialize individual
    // members separately.
    Person noone;
    strcpy(noone.name, "Davy Jones");
    noone.age = 99;
    // Note that we haven't initialized everything; check the output!

    char ident[1000];

    jane.tostring(ident);
    printf("Jane ==> %s\n", ident);
    john.tostring(ident);
    printf("John ==> %s\n", ident);
    noone.tostring(ident);
    printf("noone ==> %s\n", ident);

    return 0;
}
Exemplo n.º 5
0
int main()
{
	Bureaucrat john("John", 1);
	Bureaucrat julie("Julie", 150);
	
	try {
		Form residence("Residence", 16, 17);
		std::cout << john << std::endl;
		std::cout << residence << std::endl;
		john.signForm(residence);
		std::cout << residence << std::endl;		
	}
	catch (std::exception &e)
	{
		std::cout << e.what() << std::endl;
	}

	

	std::cout << std::endl;
	
	try {
		Form residence("Residence", 16, 17);
		std::cout << julie << std::endl;
		std::cout << residence << std::endl;	
		julie.signForm(residence);

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

	std::cout << std::endl;
	
	try {
		Form irs = Form("IRS", 1, 151);
		std::cout << irs << std::endl;
		julie.signForm(irs);
		std::cout << irs << std::endl;
		julie.decrementGrade();
	}
	catch (std::exception &e)
	{
		std::cout << e.what() << std::endl;
	}

	std::cout << std::endl;
	
	try {
		Form water = Form("water", 0, 150);
		std::cout << water << std::endl;
		julie.signForm(water);
		std::cout << water << std::endl;
		julie.decrementGrade();
	}
	catch (std::exception &e)
	{
		std::cout << e.what() << std::endl;
	}
}
Exemplo n.º 6
0
int main(int argc, char *argv[])
{
    // Creation des abonnes, des etudiants et des professeurs
    Abonne john("1839456", "Doe", "John", 23);
    Abonne nicolas("1630236", "Gagnon", "Nicolas", 8);
    Abonne martin("1269348", "Tremblay", "Martin", 18);
    Etudiant harry("1782965", "Potter", "Harry", 21, "Pourdlard");
    Etudiant hermione("1876458", "Granger", "Hermione", 20, "Pourdlard");
    EtudiantBaccalaureat tony("1865487", "Stark", "Tony", 42);
    Professeur albus("p878546", "Dumbledore", "Albus", 78, { "Polytechnique", "UdM", "Poudlard" });

    // Création des livres et DVD
    Livre livre1("BD302", "Harry Potter et le prisionier d'Azkaban", 1999, 3, 17, "JK ROWLING", "Science-Fiction");
    Livre livre2("QA204", "Calcul a plusieurs variables partie 2", 2011, 3, 1, "Cay HORTSTMANN", "Informatique");
    Livre livre3("GA403", "Big C++", 2009, 8, 2, "Cay HORTSTMANN", "Informatique");
    Livre livre4("AC409", "Le chateau d'Ortrante", 1764, 16, 2, "Cay HORTSTMANN", "Informatique");
    Livre livre5("QA203", "Calcul a plusieurs variables partie 1", 2011, 3, 1, "Cay HORTSTMANN", "Informatique");
    Livre livre6("GA404", "Big C++", 2016, 8, 2, "Cay HORTSTMANN", "Informatique");

    Dvd dvd1("D8403", "Rush Hour", 1998, 2, 13, "Al", { "Jackie Chan", "Chris Tucker" });
    Dvd dvd2("D7203", "Avenger", 2012, 3, 5, "Nick Fury", { "Iron Man", "Thor","Hulk", "Captain America", "Black Window" });

    // Creation de la bibliotheque, et ajout des elements
    Bibliotheque biblio;

    //Ajout des Abonnes
    biblio += &john;	biblio += &nicolas;	biblio += &martin;
    biblio += &harry;	biblio += &tony;	biblio += &hermione;
    biblio += &albus;

    // Ajout des livres et DVD
    biblio += &livre1;	biblio += &livre2;	biblio += &livre3;
    biblio += &livre4;	biblio += &livre5;	biblio += &livre6;
    biblio += &dvd1;	biblio += &dvd2;

    // Creation des objets numeriques et ajout à la bibliotheque
    LivreNumerique livNum1(FORMAT_EPUB, 1270, "vvv.3Mousquetaire.com", "NUM392",
                           "Les 3 mousquetaires", 1844, 11, 5, "A. Dumas", "Roman");
    LivreNumerique livNum2(FORMAT_EPUB, 1270, "vvv.3Mousquetaire.com", "NUM393",
                           "Les 3 mousquetaires 2", 1846, 11, 5, "A. Dumas", "Roman");
    biblio += &livNum1;
    biblio += &livNum2;

    // Création du vecteur pour effectuer les emprunts
    vector<pair<string,string> > vecEmp {make_pair("1630236","BD302"), make_pair("1630236","D7203"),
                                         make_pair("1782965","AC409"), make_pair("1782965","BD302"),
                                         make_pair("1782965","D7203"), make_pair("1782965","QA203"),
                                         make_pair("1865487","AC409"), make_pair("1865487","BD302"),
                                         make_pair("1865487","D7203"), make_pair("1865487","QA204"),
                                         make_pair("1865487","NUM392"), make_pair("p878546","BD302"),
                                         make_pair("p878546","D7203"), make_pair("p878546","NUM392")};
	// Effectue les emprunts
    for (size_t i = 0; i < vecEmp.size(); i++) {
        try {
            biblio.emprunter(vecEmp[i].first, vecEmp[i].second, 160204);
        } catch (exception&) {}
    }


    QApplication a(argc, argv);
    MainWindow w(&biblio);
    w.show();

    return a.exec();
}