#include
#include
#include
Copyright By PowCoder代写 加微信 powcoder
using namespace std;
class Shape
// implement this friend function for comparing shapes
friend int compare(Shape, Shape);
// default constructor
// pointers should be initialized to NULL, numbers to zero
Shape::Shape()
// Complete the following access function, and implement other access functions
void Shape::setName(char* n)
// Complete the friend function
// if s1 beats s2, returns 1
// if s2 beats s1, returns -1
// if s1 equals s2, returns 0
int compare(Shape s1, Shape s2)
int result = 0;
return result;
// Used in question 2
int deal(Shape& sysShape, int hand, Shape& userShape);
const int MAX_NUM = 10;
int main()
//The system shape
Shape sysShape;
char shapeName[][10] = { “Rock”,”Paper”, “Scissors” };
cout << "Enter the seed for random number generation: ";
cin >> seed;
srand(seed); // this sets the seed of random number generation
// the following codes are used in question 2
// game begins
int hand = 1, balance = 10;
Shape userShape;
cout << "### CS2313 Rock-Paper-Scissors Game Begins! ###\n### Note: 1 = Rock, 2 = Paper, 3 = Scissors ###\n"; for (;(hand <= MAX_NUM) && balance > 0; hand++)
if (balance > 0) {
cout << "Game ends, you have " << balance << " dollars. Congratulations!" << endl;
cout << "Game ends, you are broke!" << endl;
// check if the system shape wins or loses compared with the user's choice.
int deal(Shape& sysShape, int i, Shape& userShape)
cout << "Hand " << i << ": " << userShape.getName() << " (Yours) vs ";
cout << sysShape.getName() << ". ";
int result = compare(sysShape, userShape);
return result;
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com