Here are a few issues I could spot:
- fight method (in all three subclassses) : you only declare an argument type (
Paper
,
Rock
, etc.), but you do not provide any name to your parameters; thus, you cannot use them in the method. Moreover, in these methods, you create new unitialized instances of objects inside the method, whereas you should instead use the current instance AND the parameter.
For example:
bool fight(Paper) {
Paper p1;
Scissors s1;
return p1.strength < s1.strength;
}
would rather be
bool Fight(Paper p1) {
return p1.strength < strength;
}
... and so on for other occurrences of
Fight
method.
-
getType
method: you could just assign the
type
variable its value in the constructors of the subclasses; there is no reason to reset this value in the
setStrength
method, whose responsibility is not to deal with the
type
variable.
For example:
class Tool {
protected:
Tool(const char t) : type(t) { }
};
class Scissors : public Tool {
public:
Scissors() : Tool('s') { }
};
- in the
main
method, you are using constructors whose declarations/definitions you did not show.
I will not correct your
whole code, though, for a couple of reasons:
- you will learn much more by identifying, understanding and resolving the issues yourself, rather than someone doing it for you.
- this task is quite beyond the time I am willing/can afford to spend on a quick answer post.
I hope these few lines will put you on the right way, though.
Kindly.