Could someone help with this code
#include "Armour.h"
//------------------------------------------------------------------------------
Armour::Armour()
:Item("Armour", false), // There should be something simliar in Consumable.cpp
material(),
modifier()
{
this->durability = 0;
this->defense = 0;
this->modifierLevel = 1;
}
//------------------------------------------------------------------------------
void Armour::display(std::ostream& outs) const
{
// Implement this function
}
//------------------------------------------------------------------------------
void Armour::read(std::istream& ins)
{
// Implement this function
}
//------------------------------------------------------------------------------
Item* Armour::clone() const
{
// Implement this function
return nullptr; // remove this line
}
//Consumable.cpp
#include "Consumable.h"
//------------------------------------------------------------------------------
Consumable::Consumable()
{
}
//------------------------------------------------------------------------------
//void Consumable::display(std::ostream& outs) const
// Add the definition for this function
//------------------------------------------------------------------------------
// void Consumable::read(std::istream& ins)
// Add the definition for this function
//------------------------------------------------------------------------------
// Item* Consumable::clone() const
// Add the definition for this function
//Consumable.h
#ifndef CONSUMABLE_H_INCLUDED
#define CONSUMABLE_H_INCLUDED
#include "Item.h"
/**
* This class represents one Consumable Item--as found in most video games.
* This includes food.
*
* Consumable Items must be stackable. All Constructors must initialize
* Item::stackable to true.
*/
class Consumable : public Item {
private:
protected:
/**
* The effect recieved by using the Item.
*/
std::string effect;
/**
* Number of time this Item can be used.
*/
int uses;
public:
/**
* Default to a Comsumable Item with an empty name
*/
Consumable();
// Big-3
Consumable(const Consumable& src) = default;
~Consumable() = default;
Consumable& operator=(Consumable& rhs) = default;
/**
* Retrieve effect
*/
std::string getEffect() const;
/**
* Set effect
*/
void setEffect(std::string effect);
/**
* Retrieve number of uses
*/
int getNumberOfUses() const;
/**
* Set number of uses
*/
void setNumberOfUses(int u);
/**
* Print the Consumable Item
*/
virtual void display(std::ostream& outs) const;
/**
* Read Consumable Item attributes from an input stream
*/
virtual void read(std::istream& ins);
/**
* Clone--i.e., copy--this Consumable Item
*/
virtual Item* clone() const;
};
//------------------------------------------------------------------------------
inline
std::string Consumable::getEffect() const
{
return this->effect;
}
//------------------------------------------------------------------------------
inline
void Consumable::setEffect(std::string effect)
{
this->effect = effect;
}
//---------------------------------------------.
Could someone help with this code include Armourh .pdf
1. Could someone help with this code
#include "Armour.h"
//------------------------------------------------------------------------------
Armour::Armour()
:Item("Armour", false), // There should be something simliar in Consumable.cpp
material(),
modifier()
{
this->durability = 0;
this->defense = 0;
this->modifierLevel = 1;
}
//------------------------------------------------------------------------------
void Armour::display(std::ostream& outs) const
{
// Implement this function
}
//------------------------------------------------------------------------------
void Armour::read(std::istream& ins)
{
// Implement this function
}
//------------------------------------------------------------------------------
Item* Armour::clone() const
{
// Implement this function
return nullptr; // remove this line
}
//Consumable.cpp
#include "Consumable.h"
//------------------------------------------------------------------------------
Consumable::Consumable()
{
}
//------------------------------------------------------------------------------
//void Consumable::display(std::ostream& outs) const
// Add the definition for this function
//------------------------------------------------------------------------------
// void Consumable::read(std::istream& ins)
// Add the definition for this function
//------------------------------------------------------------------------------
// Item* Consumable::clone() const
2. // Add the definition for this function
//Consumable.h
#ifndef CONSUMABLE_H_INCLUDED
#define CONSUMABLE_H_INCLUDED
#include "Item.h"
/**
* This class represents one Consumable Item--as found in most video games.
* This includes food.
*
* Consumable Items must be stackable. All Constructors must initialize
* Item::stackable to true.
*/
class Consumable : public Item {
private:
protected:
/**
* The effect recieved by using the Item.
*/
std::string effect;
/**
* Number of time this Item can be used.
*/
int uses;
public:
/**
* Default to a Comsumable Item with an empty name
*/
Consumable();
// Big-3
Consumable(const Consumable& src) = default;
~Consumable() = default;
Consumable& operator=(Consumable& rhs) = default;
/**
* Retrieve effect
*/
std::string getEffect() const;
/**
* Set effect
*/
void setEffect(std::string effect);
/**
* Retrieve number of uses
4. }
#endif
//Armour.h
#ifndef ARMOUR_H_INCLUDED
#define ARMOUR_H_INCLUDED
#include "Item.h"
/**
* This class represents one piece of armour--as found in most video games.
* This includes boots and helmets.
*
* Armour may not be stacked. All Constructors must initialize Item::stackable
* to false.
*/
class Armour : public Item {
private:
protected:
double durability; ///< decreases each time the armour is used
double defense; ///< damage that is blocked
std::string material; ///< material out of which the armour is composed
std::string modifier; ///< one of protection, feather_falling, or unbreaking
int modifierLevel; ///< modifier level in the range 1 to 3
std::string element; ///< associated element--e.g., ice, fire, and lightning.
public:
/**
* Default to a armour with an empty name
*/
Armour();
// Big-3
Armour(const Armour& src) = default;
~Armour() = default;
Armour& operator=(const Armour& rhs) = default;
/**
* Retrieve armour durability
*/
double getDurability() const;
/**
* Set armour durability
*/
void setDurability(double durability);
/**
* Retrieve armour defense
*/
5. double getDefense() const;
/**
* Set armour defense
*/
void setDefense(double defense);
/**
* Retrieve armour Material
*/
std::string getMaterial() const;
/**
* Set armour Material
*/
void setMaterial(std::string m);
/**
* Retrieve armour Modifier
*/
std::string getModifier() const;
/**
* Set armour Modifier
*/
void setModifier(std::string m);
/**
* Retrieve armour Modifier Level
*/
double getModifierLevel() const;
/**
* Set armour Modifier Level
*/
void setModifierLevel(double level);
/**
* Retrieve armour Element
*/
std::string getElement() const;
/**
* Set armour Element
*/
void setElement(std::string e);
/**
* Print one Armour
*/
virtual void display(std::ostream& outs) const;
/**
7. this->material = m;
}
//------------------------------------------------------------------------------
inline
std::string Armour::getModifier() const
{
return this->modifier;
}
//------------------------------------------------------------------------------
inline
void Armour::setModifier(std::string m)
{
this->modifier = m;
}
//------------------------------------------------------------------------------
inline
double Armour::getModifierLevel() const
{
return this->modifierLevel;
}
//------------------------------------------------------------------------------
inline
void Armour::setModifierLevel(double level)
{
this->modifierLevel = level;
}
//------------------------------------------------------------------------------
inline
std::string Armour::getElement() const
{
return this->element;
}
//------------------------------------------------------------------------------
inline
void Armour::setElement(std::string e)
{
this->element = e;
}
#endif
Only Armour.cpp and Consumable.cpp need to be changed
1.3 Your Tasks The key abstractions employed in this program are Item, Itemstack, Inventory
Armour, and Consumable. Your overall task is to complete the Armour and Consumable ADTs. 1.
8. As an initial step, you will need to complete the Armour and Consumable Default Constructors: A.
Set the stackable attribute-i.e., stackable. Hint Remember initializer lists? B. Set the name
attribute-i.e., Item: : name. The attribute, name, is a protected data member of Item. 2. Implement
Armour: :clone and Consumable:: clone. 3. Implement Armour: : read and Consumable: : read. 4.
Implement Armour: : display and Consumable : : display. You are expected to generate additional
input files to test your code. Test your code throughly before submitting y 1.3.1 Expected Initial
Error Messages If you run make without adding the missing read, clone, and display methods, you
will see something simliar to /usr/bin/ld.gold: the vtable symbol may be undefined because the
class is missing its key function Armour. cpp:14: error: undefined reference to 'vtable for Armour'
/usr/bin/ld.gold: the vtable symbol may be undefined because the class is missing its key function
Consumable.cpp:4: error: undefined reference to 'vtable for Consumable' /usr/bin/ld.gold: the
vtable symbol may be undefined because the class is missing its key function
Consumable.cpp:12: error: undefined reference to 'vtable for Consumable' /usr/bin/ld.gold: the
vtable symbol may be undefined because the class is missing its key function collect2: error: ld
returned 1 exit status make: *** [storage] Error 11.3.2 Testing Your Code I have provided you a set
of unit tests. In addition to your normal checks (e.g., running the completed program and
performing headto-head testing) run the unit tests with make tests ./ testNewClasses You should
see: PASSED testDefaultArmourConstructor PASSED - testArmourCopyConstructor PASSED
testArmourClone PASSED testArmourDisplay PASSED testArmourRead PASSED
testDefaultConsumableConstructor PASSED testConsumableCopyConstructor PASSED
testConsumableClone PASSED - testConsumableDisplay PASSED testConsumableRead