Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions

Question

2. (1 point) Given AABC, tan A b b

Answered: 1 week ago