Welcome!
Log In
Create A New Profile
Home
>
2006
>
COS112V
> Topic
Advanced
What seems to be wrong with this code fragment ?
Posted by
Wiseguy
Announcements
Last Post
SoC Curricula
09/30/2017 01:08PM
Demarcation or scoping of examinations and assessment
02/13/2017 07:59AM
School of Computing Short Learning Programmes
11/24/2014 08:37AM
Unisa contact information
07/28/2011 01:28PM
Forums
Messages
New
Wiseguy
What seems to be wrong with this code fragment ?
May 10, 2006 01:29PM
IP/Host: ---.sanlam.co.za
Registered: 18 years ago
Posts: 560
Rating: 2
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 ??
Reply
Quote
Anonymous User
Re: What seems to be wrong with this code fragment ?
May 10, 2006 03:13PM
IP/Host: 163.195.192.---
Rating: 0
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.
Reply
Quote
whatever
Re: What seems to be wrong with this code fragment ?
May 11, 2006 10:22AM
IP/Host: ---.is.co.za
Registered: 18 years ago
Posts: 8
Rating: 0
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;
Reply
Quote
Wiseguy
Re: What seems to be wrong with this code fragment ?
May 12, 2006 08:20AM
IP/Host: ---.sanlam.co.za
Registered: 18 years ago
Posts: 560
Rating: 2
Thanks guys !
Reply
Quote
Brendonw
Re: What seems to be wrong with this code fragment ?
May 16, 2006 01:31PM
IP/Host: 196.211.24.---
Registered: 18 years ago
Posts: 88
Rating: 0
Fellow Students
Who completed assignment 2 question 5.
Reply
Quote
T|mo
Re: What seems to be wrong with this code fragment ?
May 16, 2006 07:44PM
IP/Host: ---.gprs.vodacom.co.za
Registered: 18 years ago
Posts: 9
Rating: 0
I did
, they could of given us some more test data or at least some usefull data
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
Reply
Quote
Brendonw
Re: What seems to be wrong with this code fragment ?
May 17, 2006 02:01PM
IP/Host: 196.211.24.---
Registered: 18 years ago
Posts: 88
Rating: 0
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.
Reply
Quote
Newer Topic
Older Topic
Print View
RSS
Sorry, only registered users may post in this forum.
Click here to login