92 lines
4.3 KiB
C++
92 lines
4.3 KiB
C++
/* ************************************************************************** */
|
|
/* */
|
|
/* :::::::: */
|
|
/* main.cpp :+: :+: */
|
|
/* +:+ */
|
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
|
/* +#+ */
|
|
/* Created: 2025/04/05 17:06:50 by whaffman #+# #+# */
|
|
/* Updated: 2025/04/05 18:01:03 by whaffman ######## odam.nl */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "Animal.hpp"
|
|
#include "WrongAnimal.hpp"
|
|
#include "Dog.hpp"
|
|
#include "Cat.hpp"
|
|
#include "WrongCat.hpp"
|
|
#include <iostream>
|
|
|
|
int main(void)
|
|
{
|
|
std::cout << "Construct Animal, Cat and Dog" << std::endl;
|
|
std::cout << "----------------------------------------" << std::endl;
|
|
std::cout << "construct an animal:" << std::endl;
|
|
const Animal* animal = new Animal();
|
|
std::cout << "construct a cat:" << std::endl;
|
|
const Animal* cat = new Cat();
|
|
std::cout << "construct a dog:" << std::endl;
|
|
const Animal* dog = new Dog();
|
|
std::cout << "========================================" << std::endl << std::endl;
|
|
|
|
std::cout << "test the getType function" << std::endl;
|
|
std::cout << "----------------------------------------" << std::endl;
|
|
std::cout << "animal is of type : " << animal->getType() << std::endl;
|
|
std::cout << "cat is of type : " << cat->getType() << std::endl;
|
|
std::cout << "dog is of type : " << dog->getType() << std::endl;
|
|
std::cout << "========================================" << std::endl << std::endl;
|
|
|
|
std::cout << "test the makeSound function" << std::endl;
|
|
std::cout << "----------------------------------------" << std::endl;
|
|
std::cout << "animal sound : ";
|
|
animal->makeSound();
|
|
std::cout << std::endl;
|
|
std::cout << "cat sound : ";
|
|
cat->makeSound();
|
|
std::cout << "dog sound : ";
|
|
dog->makeSound();
|
|
std::cout << "========================================" << std::endl << std::endl;
|
|
|
|
std::cout << "test the destructor" << std::endl;
|
|
std::cout << "----------------------------------------" << std::endl;
|
|
std::cout << "delete animal:" << std::endl;
|
|
delete animal;
|
|
std::cout << "delete cat:" << std::endl;
|
|
delete cat;
|
|
std::cout << "delete dog:" << std::endl;
|
|
delete dog;
|
|
std::cout << "========================================" << std::endl << std::endl;
|
|
|
|
std::cout << "Construct WrongAnimal, WrongCat" << std::endl;
|
|
std::cout << "----------------------------------------" << std::endl;
|
|
std::cout << "construct a wrongAnimal:" << std::endl;
|
|
const WrongAnimal* wrongAnimal = new WrongAnimal();
|
|
std::cout << "construct a wrongCat:" << std::endl;
|
|
const WrongAnimal* wrongCat = new WrongCat();
|
|
std::cout << "========================================" << std::endl << std::endl;
|
|
|
|
std::cout << "test the getType function" << std::endl;
|
|
std::cout << "----------------------------------------" << std::endl;
|
|
std::cout << "wrongAnimal is of type : " << wrongAnimal->getType() << std::endl;
|
|
std::cout << "wrongCat is of type : " << wrongCat->getType() << std::endl;
|
|
std::cout << "========================================" << std::endl << std::endl;
|
|
|
|
std::cout << "test the makeSound function" << std::endl;
|
|
std::cout << "----------------------------------------" << std::endl;
|
|
std::cout << "wrongAnimal sound : ";
|
|
wrongAnimal->makeSound();
|
|
std::cout << std::endl;
|
|
std::cout << "wrongCat sound : ";
|
|
wrongCat->makeSound();
|
|
std::cout << "========================================" << std::endl << std::endl;
|
|
|
|
std::cout << "test the destructor" << std::endl;
|
|
std::cout << "----------------------------------------" << std::endl;
|
|
std::cout << "delete wrongAnimal:" << std::endl;
|
|
delete wrongAnimal;
|
|
std::cout << "delete wrongCat:" << std::endl;
|
|
delete wrongCat;
|
|
std::cout << "========================================" << std::endl << std::endl;
|
|
|
|
return 0;
|
|
} |