problem with rock paper scissors game

I am supposed to make a rock paper scissors game, but using function prototypes
such as:
1.int random();
2. string input();
3. string compChoice(int);
4. void displayCompChoice(string);
5. bool compare(string, string)
But there are some problems such as:
1.main.cpp:18:14: error: expected initializer before ‘compchoice’
2.main.cpp:26:23: error: no match for ‘operator!=’ (operand types are ‘std::string {aka std::basic_string}’ and ‘int’)
3.main.cpp:26:42: error: no match for ‘operator!=’ (operand types are ‘std::string {aka std::basic_string}’ and ‘int’)
4.main.cpp:26:61: error: no match for ‘operator!=’ (operand types are ‘std::string {aka std::basic_string}’ and ‘int’)
5.main.cpp:45:14: error: expected initializer before ‘compchoice’

Here is the code:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
  #include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
using namespace std;
string Userchoice();
int main();
void display compchoice(int);
bool compare (string, string);

string Userchoice ()   //this is: string input
{
  string Userchoice;
  cout << "Choose rock=1, scissors=2, paper=3";
    cin >> Userchoice;
    while (Userchoice != 3 && Userchoice != 2 && Userchoice != 1)
    {
      cout << "Choose rock=1, paper=2, scissors=3:";
      cin >> Userchoice;
    }
  return Userchoice;
}

int
main ()
{

  srand (time (NULL));
  int x;
  x = rand () % 3 + 1;		//generate random number from 1-3(int random & int compchoice)
  cout << x << " ";
  return 0;
}

void display compchoice (int x)
{
  if (computer_choice == 1)
    {
      cout << "Computer chose 1" << endl;
    }
  else if (computer_choice == 2)
    {
      cout << "Computer chose 2" << endl;
    }
  else				//if (computer_choice==3)
    {
      cout << "Computer chose 3" << endl;
    }
}

bool compare (comp_choice, user_choice)
{
  if (user_choice == 1 && computer_choice == 2)
    {
      cout << "computer wins" << endl;

    }
  else if (user_choice == 2 && computer_choice == 3)
    {
      cout << "computer wins" << endl;

    }
  else if (user_choice == 3 && computer_choice == 1)
    {
      cout << "computer wins" << endl;

    }
  else if (computer_choice == 1 && user_choice == 2)
    {
      cout << "user winsuser wins" << endl;

    }
  else if (computer_choice == 2 && user_choice == 3)
    {
      cout << "user winsuser wins" << endl;

    }
  else if (computer_choice == 3 && user_choice == 1)
    {
      cout << "user wins" << endl;
    }
  else if (computer_choice == user_choice)
    {
      cout << "it's a tie" << endl;

    }
  return 0;
}
> void display compchoice(int);
Function names can't have spaces in them.

> bool compare (comp_choice, user_choice)
Your parameters need types (int, string, etc).
Topic archived. No new replies allowed.