예제 #1
0
파일: main.c 프로젝트: xichen2004/OOAnimal
int main(int argc, char *argv[])
{
	Animal animal;
	Bird bird, mutantBird;
	Cat cat;
	Crow crow;

	newAnimal(&animal);
	animal.setName(&animal, animalName);

	newBird(&bird);
	((Animal *) &bird)->setName((Animal *) &bird, birdName);

	newBird(&mutantBird);
	((Animal *) &mutantBird)->setName((Animal *) &mutantBird, mutantBirdName);
	((Animal *) &mutantBird)->setLegs((Animal *) &mutantBird, 3);

	newCat(&cat);
	((Animal *) &cat)->setName((Animal *) &cat, catsName);

	newCrow(&crow);
	((Animal *) &crow)->setName((Animal *) &crow, crowName);

	test_animal(&animal);
	test_animal((Animal *) &bird);
	test_animal((Animal *) &mutantBird);
	test_animal((Animal *) &cat);
	test_animal((Animal *) &crow);

	test_cat(&cat);

	test_bird(&bird);
	test_bird((Bird *) &mutantBird);
	test_bird((Bird *) &crow);

	test_crow(&crow);

	return 0;
}
예제 #2
0
//---------------------------------------------------------------------------//
// the main program
int main()
{

  // run some tests
  try
  {
    test_plant();
    test_organism();
    test_animal();
    test_forest();
    test_time();
  }
  // catch error of type CppException
  catch (const CppException & err)
  {
    err.Report();
    return 1;
  }

  return 0;
}