Help please

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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#include <iostream>

using namespace std;

char moveto;

void z()
{
    cout<<"You are now standing on z. Were do you want to move?\n";
    cout<<"[q][w][e]\n[a][s][d]\n[0][x][c]\n";
    cin>> moveto;
}

void x()
{
    cout<<"You are now standing on x. Were do you want to move?\n";
    cout<<"[q][w][e]\n[a][s][d]\n[z][0][c]\n";
    cin>> moveto;
}

void c()
{
    cout<<"You are now standing on c. Were do you want to move?\n";
    cout<<"[q][w][e]\n[a][s][d]\n[z][x][0]\n";
    cin>> moveto;
}

void a()
{
    cout<<"You are now standing on a. Were do you want to move?\n";
    cout<<"[q][w][e]\n[0][s][d]\n[z][x][c]\n";
    cin>> moveto;
}

void s()
{
    cout<<"You are now standing on s. Were do you want to move?\n";
    cout<<"[q][w][e]\n[a][0][d]\n[z][x][c]\n";
    cin>> moveto;
}

void d()
{
    cout<<"You are now standing on d. Were do you want to move?\n";
    cout<<"[q][w][e]\n[a][s][0]\n[z][x][c]\n";
    cin>> moveto;
}

void q()
{
    cout<<"You are now standing on q. Were do you want to move?\n";
    cout<<"[0][w][e]\n[a][s][d]\n[z][x][c]\n";
    cin>> moveto;
}

void w()
{
    cout<<"You are now standing on w. Were do you want to move?\n";
    cout<<"[q][0][e]\n[a][s][d]\n[z][x][c]\n";
    cin>> moveto;
}

void e()
{
    cout<<"You are now standing on e. Were do you want to move?\n";
    cout<<"[q][w][0]\n[a][s][d]\n[z][x][c]\n";
    cin>> moveto;
    choosevoid;
}

void choosevoid()
{
   switch ( moveto ) {
        case 'z':
         z();
         break;
        case 'x':
         x();
         break;
        case 'c':
         c();
         break;
        case 'a':
         a();
         break;
        case 's':
         s();
         break;
        case 'd':
         d();
         break;
        case 'q':
         q();
         break;
        case 'w':
         w();
         break;
        case 'e':
         e();
         break;

    }
}


int main()
{

    cout<<"You are standing on s. Were do you want to move?\n";
    cout<<"[q][w][e]\n[a][0][d]\n[z][x][c]\n";
    cin>> moveto;
    cin.get();

    switch ( moveto ) {
        case 'z':
         z();
         break;
        case 'x':
         x();
         break;
        case 'c':
         c();
         break;
        case 'a':
         a();
         break;
        case 's':
         s();
         break;
        case 'd':
         d();
         break;
        case 'q':
         q();
         break;
        case 'w':
         w();
         break;
        case 'e':
         e();
         break;

    }
}


I have probably done this wrong, but I want it to go back and let you choose again after the first time you choose. Anyone know what is wrong?
I suggest making a function move(char direction) { }; rather than having a separate function for each move direction...

For this version to run infinitely, you'd probably have to add a call to 'choosevoid()' in every move function (like you did in e()).
just judging by what you just said and not reading your code much because im lazy ha, i'd say you just need to put everything inside main and call main with main();
Do not ever call main()!
Use a looping structure like do-while.
Topic archived. No new replies allowed.