Added: C++ projects
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// Created by David Hackbarth on 21.09.26.
|
||||
//
|
||||
|
||||
#include "Monster.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
Monster::Monster() : Entity(""), _pWeapon(new Weapon())
|
||||
{
|
||||
cout << "Monster constructor called" << endl;
|
||||
}
|
||||
|
||||
Monster::Monster(string name) : Entity(name), _pWeapon(new Weapon())
|
||||
{
|
||||
cout << "Monster constructor with name called" << endl;
|
||||
}
|
||||
|
||||
Monster::Monster(const Monster& other)
|
||||
{
|
||||
// shallow copy
|
||||
this->_name = other._name;
|
||||
// this->_pWeapon = other._pWeapon;
|
||||
|
||||
// deep copy
|
||||
this->_pWeapon = new Weapon(*other._pWeapon);
|
||||
}
|
||||
|
||||
Monster::~Monster()
|
||||
{
|
||||
cout << "Monster destructor called" << endl;
|
||||
|
||||
if (_pWeapon != nullptr)
|
||||
{
|
||||
delete _pWeapon;
|
||||
_pWeapon = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
string Monster::toString()
|
||||
{
|
||||
return "Monster: " + _name;
|
||||
}
|
||||
|
||||
int Monster::compareTo(const IComparable& other) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user