Question: Hello! I am trying to create a function lab that builds a robot through a card game. I am not able to compile it as

Hello! I am trying to create a function lab that builds a robot through a card game. I am not able to compile it as it returns an error message of

"Called object type 'int' is not a function of function pointer"

on the line beggining with "While ( Completed()".... How to I resolve this issue and succesfully compile?

I am using c++ on xcode.

Thanks in advance!

#include

#include

#include

#include

#include

int Completed();

int robotfunction()

{

int Dice;

time_t t;

srand((unsigned) time(&t));

Dice=rand()%7 + 1;

printf("Dice roll count is:%d ",Dice);

return Dice;

}

bool assemble (int foot, int leg,int torso,int arm,int hand,int head,int sensor)

{

while( Completed ()(foot, leg,torso,arm,hand,head,sensor)==0)

{

printf("foot=%d , leg=%d ,torso=%d ,arm=%d ,hand=%d ,head=%d ,sensor =%d ",foot , leg,torso,arm,hand,head,sensor);

switch(robotfunction())

{

case 1:

{

if(foot<2)

foot++;

break;

}

case 2:

{

if(leg<2 && foot>= 2)

leg++;

break;

}

case 3:

{

if(leg==2 && torso<1)

torso++;

break;

}

case 4:

{

if(torso>0 && arm<2)

arm++;

break;

}

case 5:

{

if(arm> hand&& hand<2)

hand++;

break;

}

case 6:

{

if(torso >0 && head<1)

head++;

break;

}

case 7:

{

if(torso>0 && sensor<6)

sensor++;

}

}

}

return Completed();

}

int Completed(int foot, int leg,int torso,int arm,int hand,int head,int sensor){

if(foot==2 && leg==2 && torso==1 && arm==2 && hand==2 && head==1 && sensor==6)

return 1;

else

return 0;

}

int main()

{

int foot,leg,torso,arm, hand,head,sensor;

char c='Y';

printf(" Press Y to start building a robot from the beginning or Press N to end the program/n ");

while (c=='Y')

{

assemble(foot, leg,torso,arm,hand,head,sensor);

printf(" Press Y to start again Press N to exit :");

scanf("%c",&c);

}

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!