I'm supposed to use a 'top-down' programming style (which is my enemy) for a simple game of Cootie, and I am very new to C++ so there will be errors abound in my program, I'm just working on getting past one error thus far:
void ApplyRoll(int Roll, int Body, int Head, int Antennae, int Legs, int Eyes, int Lips);
It generates an error in Dev C++:
too few arguments to function `void ApplyRoll(int, int, int, int, int, int, int)'
at this point in file
Here is the complete code:
// Re-writing the Cootie program using top-down design
// Top-down programming is not my friend
#include <iostream> // use input/output functionality - STILL NEEDED??
#include <cstdlib> // for rand
#include <conio.h> // for Y/N input
using namespace std;
int main() {
srand((unsigned)time(0));
int Roll, Body, Head, Antennae, Legs, Lips, Eyes;
int RollDice();
void AddBody(int Body);
void AddHead(int Body, int Head);
void AddAntennae(int Body, int Head, int Antennae);
void AddEyes(int Body, int Head, int Eyes);
void AddLegs(int Body, int Head, int Legs);
void AddLips(int Body, int Head, int Lips);
void ApplyRoll(int Roll, int Body, int Head, int Antennae, int Legs, int Eyes, int Lips);
string PrintCootie(int Body, int Head, int Antennae, int Legs, int Eyes, int Lips);
do {
Roll = RollDice();
ApplyRoll(Roll);
PrintCootie(Body, Head, Antennae, Legs, Lips, Eyes);
while (!CootieComplete(1)) ;
}
/*** functions ***/
int RollDice() {
// roll the dice and return value
return rand() % 6 + 1;
}
void ApplyRoll(int Roll, int Body, int Head, int Antennae, int Legs, int Eyes, int Lips) {
// add the corresponding Cootie piece from the roll
if(Roll == 1) {
AddBody(Body);
}
else if(Roll == 2) {
AddHead(Body, Head);
}
else if(Roll == 3) {
AddAntennae(Body, Head, Antennae);
}
else if(Roll == 4) {
AddEyes(Body, Head, Eyes);
}
else if(Roll == 5) {
AddLips(Body, Head, Lips);
}
else if(Roll == 6) {
AddLegs(Body, Head, Legs);
}
}
// add parts
int AddBody(int Body) {
// need body first
if(Body < 1) {
Body++;
}
}
int AddHead(int Body, int Head) {
// then head
if(Head < 1 && Body == 1) {
Head++;
}
}
int AddAntennae(int Body, int Head, int Antennae) {
if(Antennae < 1 && Head == 1 && Body == 1) {
Antennae++;
}
}
int AddEyes(int Body, int Head, int Eyes) {
if(Eyes < 1 && Head == 1 && Body == 1) {
Eyes++;
}
}
int AddLips(int Body, int Head, int Lips) {
if(Lips < 1 && Head == 1 && Body == 1) {
Lips++;
}
}
int AddLegs(int Body, int Head, int Legs) {
if(Legs < 6 && Head == 1 && Body == 1) {
Legs++;
}
}
string PrintCootie(int Body, int Head, int Antennae, int Legs, int Lips, int Eyes) {
// pieces in the Cootie so far
cout << "Cootie has ";
if(Body == 1) {
cout << "body ";
}
if(Head == 1) {
cout << "head ";
}
if(Antennae == 1) {
cout << "antennae ";
}
if(Legs < 6) {
cout << "legs(" << Legs << ") ";
}
if(Lips == 1) {
cout << "lips ";
}
if(Eyes == 1) {
cout << "eyes";
}
cout << "." << endl;
}
CootieComplete() {
// return 1=finished, 0=incomplete
if (Body == 1 && Head == 1 && Antennae == 1 && Legs == 6 && Lips == 1 && Eyes == 1) {
return 1;
}
else {
return 0;
}
}
I appreciate help!