#include <iostream>
using namespace std;
bool readScore(int &thisScore, int &errorCount);
int bowl(int &pins, int thisScore, int &frames, int weight1);
int main() {
int thisScore = 0, errorCount = 0, pins = 10, frames = 0, weight1 = 0, weight2 = 0;
int status = 5;
readScore(thisScore, errorCount);
status = bowl(pins, thisScore, frames, weight1);
cout << "ThisScore: " << thisScore << endl;
cout << "Error Count: " << errorCount << endl;
cout << "Pins: " << pins << endl;
cout << "Frames: " << frames << endl;
cout << "Status: " << status << endl;
return 0;
}
bool readScore(int &thisScore, int &errorCount) {
cin >> thisScore;
return 1;
}
int bowl(int &pins, int thisScore, int &frames, int weight1) {
//Determines if score in range and updates pins accordingly
//0 = error
//1 = normal
//2 = spare
//3 = strike
//4 = in progress
if (thisScore < 0 || thisScore > 10 || (thisScore + pins) > 10){
//ERROR
return 0;
} else {
if (pins == 10) { //First Half
if (thisScore == 10) { //Strike
pins = 0;
return 3;
cout << "STRIKE";
} else { //continue frame
pins -= thisScore;
return 4;
}
} else { //Second Half
if ((pins + thisScore) == 10) { //Spare
return 2;
} else { //Normal
return 1;
}
}
}
}
Unfortunately, this returns:
(input is 10)
ThisScore: 10
Error Count: 0
Pins: 10
Frames: 0
Status: 0
Why doesnt bowl return a value (it returns 0 no matter what value I feed it) or update pins?
Any help?