Welcome! Log In Create A New Profile

Advanced

What seems to be wrong with this code fragment ?

Posted by Wiseguy 
Announcements Last Post
Announcement myUnisa availability 21 to 24 March 2019 03/17/2019 02:24PM
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
avatar What seems to be wrong with this code fragment ?
May 10, 2006 01:29PM
switch (color) {
case 'b': Black;
break;
case 'w': White;
break;
case 'r': Red;
break;
case 'g': Green;
break;
case 'B': Blue;
break;
case 'y': Yellow;
break;
case 'c': Cyan;
break;
case 'm': Magenta;
break;
default: cout << "Invalid colour!" << endl;
}



enum color {Black = 1, White = 2, Red = 3, Green = 4, Blue = 5, Yellow = 6, Cyan = 7, Magenta = 8};

RectangleShape R(W, x, y, color, w, h);


Compiler says it cannot call the function RectangleShape ??
Anonymous User
Re: What seems to be wrong with this code fragment ?
May 10, 2006 03:13PM
create a variable of type color.

e.g. color colour;

take this line out:
enum color {Black = 1, White = 2, Red = 3, Green = 4, Blue = 5, Yellow = 6, Cyan = 7, Magenta = 8};

color is a built-in type, you don't have to declare the different colours.
Re: What seems to be wrong with this code fragment ?
May 11, 2006 10:22AM
It should look like

//define variable to store colour and use in functions
color TheColour;
char StringColour='r';

switch ( StringColour ) {
case 'r' : TheColour = Red;
break;
case 'y' : TheColour = Yellow;
break;
}
//

This will allow you to use TheColour wherever you used to use the Enum values;
avatar Re: What seems to be wrong with this code fragment ?
May 12, 2006 08:20AM
Thanks guys !
Re: What seems to be wrong with this code fragment ?
May 16, 2006 01:31PM
Fellow Students

Who completed assignment 2 question 5.
Re: What seems to be wrong with this code fragment ?
May 16, 2006 07:44PM
I did smiling smiley, they could of given us some more test data or at least some usefull data tongue sticking out smiley

Is it just me or do these assignments take years to get marked?

I havent gotten any of my programming assignments back...

How bout you okes?

Tim
Re: What seems to be wrong with this code fragment ?
May 17, 2006 02:01PM
Nothing, we received the answers on ass1, but nothing on marks yet. I think that you qualify for all 10 credits just for sending the ass1 for COS112V.
Sorry, only registered users may post in this forum.

Click here to login