aggretion relationship c++
//KURTLAR VADİSİ
#include<iostream>
using namespace std;
class Silah
{
public:
virtual void silahKullan()=0;
};
class Baretta:public Silah
{
public:
void silahKullan()
{
cout<<"Barettamla ateş ediyorum ****"<<endl;
}
};
class Bicak:public Silah
{
public:
void silahKullan()
{
cout<<"Bicagimla yaraladim ****"<<endl;
}
};
class Bomba:public Silah
{
public:
void silahKullan()
{
cout<<"Bombayi attim! KAÇ !! ****"<<endl;
}
};
class Karakter
{
public:
virtual void Display() = 0;
void silahSec(Silah *s)
{
this->silah=s;
}
void fight()
{
silah->silahKullan();
}
protected:
Silah *silah;
};
class Polat:public Karakter
{
public:
void Display()
{
cout<<"Ben Polat"<<endl;
}
};
class Memati:public Karakter
{
public:
void Display()
{
cout<<"Ben Memati"<<endl;
}
};
class Abdulhey:public Karakter
{
public:
void Display()
{
cout<<"Ben Abdulhey"<<endl;
}
};
int main()
{
Karakter *karakter = new Polat();
karakter->silahSec(new Bomba);
karakter->Display();
karakter->fight();
Silah *silah=new Baretta();
Karakter *memati=new Memati();
memati->silahSec(silah);
memati->Display();
memati->fight();
Karakter *abdulhey=new Abdulhey();
abdulhey->silahSec(new Bicak);
abdulhey->Display();
abdulhey->fight();
cout<<"nnoperasyon bitti dönüyoruz.."<<endl;
return 0;
}