Last active
February 14, 2023 04:38
-
-
Save prestonvasquez/6c67b70e2705394a91a304010fa3a458 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include <iostream> | |
using namespace std; | |
// Base class | |
class Player { | |
public: | |
// pure virtual function providing interface framework. | |
virtual int getMove() = 0; | |
}; | |
// Derived classes | |
class Human: public Player { | |
public: | |
int getMove() { | |
// TODO: add logic | |
return 1; | |
} | |
}; | |
class Computer: public Player { | |
public: | |
int getMove() { | |
// TODO: add logic | |
return 0; | |
} | |
}; | |
int battle(Player &p1, Player &p2) { | |
return p1.getMove() + p2.getMove(); | |
} | |
int main(void) { | |
Human p1; | |
Computer p2; | |
cout << "value: " << battle(p1, p2) << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment