Created
April 13, 2017 10:49
-
-
Save Pethaf/dbce33519a7dec5caa3e1fcd6effb2ba to your computer and use it in GitHub Desktop.
Override
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef vector<int> vint; | |
class Score_Variant | |
{ | |
public: | |
virtual ~Score_Variant() = default; | |
virtual string name() const { return to_str();} | |
virtual int score(const vint&) = 0; | |
protected: | |
Score_Variant() = default; | |
private: | |
Score_Variant& operator=(const Score_Variant&) = delete; | |
Score_Variant(Score_Variant&) = delete; | |
Score_Variant(Score_Variant&&) = delete; | |
virtual string to_str() const = 0; | |
}; | |
class Pair: public Score_Variant{ | |
public: | |
virtual ~Pair() = default; | |
Pair() = default; | |
virtual int score(const vint& diceRolls ) override | |
{ sort(begin(diceRolls),end(diceRolls)); | |
auto tmp = adjacent_find(rbegin(diceRolls),rend(diceRolls)); | |
if(tmp != rend(diceRolls)) | |
{ | |
return (*tmp)*2; | |
} | |
else | |
{ | |
return 0; | |
} | |
} | |
private: | |
Pair(const Pair&) = delete; | |
Pair(Pair&&) = delete; | |
Pair& operator=(const Pair&) = delete; | |
virtual string to_str() const override { return "Twos";} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment