I managed to get the value of an enum via reflection. I have to use reflection since I have different objects with enums in them. But how do I get the name of the enum? Let's say I have [CODE] enum MyEnum { A, B } [/CODE] I can get [ICODE]if (strValue.Equals("A"))[/ICODE] as a result, but how do I get [ICODE]if (strName.Equals("MyEnum"))[/ICODE]? I do have to mention that the enums are nullable! To be more specific this is the method I want to use: [CODE] static void DumpProperties(object the_object) { // Write the string to a file. System.IO.StreamWriter file = …

Member Avatar
Member Avatar
+0 forum 4

In the following code I'm trying to make "SRAM", "FRAM", "EEPROM", and "FLASH" constants, MEM_TYPE an 8-bit variable that can be changed by other programs. The pointer should be pointing to MEM_TYPE. I'm getting a error under uint8_t (defined as BYTE elsewhere in an included file), "*", *and enum which is causing the rest to be errored as well. I copied the format of another's program that I can't post here. What am I really doing? And how do I fix it? uint8_t volatile * const enum { SRAM, FRAM, EEPROM, FLASH }MEM_TYPE;

Member Avatar
Member Avatar
+0 forum 1

I am trying to get the following ENUM to work, but it's not working. Any help is appreciated. class Colour(Enum): WHITE = (255,255,255) BLACK = (0,0,0) RED = (215,45,45) BLUE = (45,87,214) YELLOW = (230,223,48) GREEN = (45,194,64) Using it: `Colour.BLACK` Error: /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 "/Users/blooop/main.py" Traceback (most recent call last): File "/Users/bloopppp/main.py", line 27, in <module> gameDisplay.fill(Colour.BLACK) TypeError: invalid color argument Process finished with exit code 1 I'm still learning Python, so all help is greatly appreciated! Thank you!

Member Avatar
Member Avatar
+0 forum 6

Maybe a bit silly question, but in one of my projects I needed an enum and I suddenly wondered what would be the best place for it to write it in a file. Should it be in a .cs file of his own or could I place it in the class file where it is mostly used? Thanks in advance for any enlightment.

Member Avatar
Member Avatar
+0 forum 3

is there an easier way to write this code?? without using enum, enum MenuState{MenuPlay,MenuHelp,MenuExit}; MenuState ms=MenuPlay; char ch=0;//or anything other than '\r' while (ch!='\r')//IIRC getch returns '\r' when user hits enter { switch (ms) { case MenuPlay: cout<<"--> PLAY\n HELP\n EXIT\n"; break; case MenuHelp: cout<<" PLAY\n--> HELP\n EXIT\n"; break; case MenuExit: cout<<" PLAY\n HELP\n--> EXIT\n"; break; default: //always provide default, some compilers will not compile until it is there cout<<"ERROR: Unknown state!\n"; } ch=getch();//process more input switch (ch) { case 'w': case 'W': ms=MenuPlay; break; case 'e': case 'E': ms=MenuHelp; break; case 'r': case 'R': ms=MenuExit; break; default: } } …

Member Avatar
Member Avatar
+0 forum 2

Similarly, you can add more fields to an enum and simply provide accessor methods to retrieve them. For example you could change it to have an extra field indicating an output directory to write specific types of data to, and a getter method to return that directory.

Member Avatar
Member Avatar
+0 forum 2

Having issues with array. Seems to pull in the enum files (month and average rainfall) and print accordingly. Also seems to read in the updated rainfall per month. However, problem is I can not make updated print with the enum. Also, last line in program has ..."actual[i]". If use a value for the i, will get that value printed. If leave with variable, get error message which points to this issue....."at Rainfall.main(Rainfall.java:52)" Any help appreciated. import java.util.Scanner; public class Rainfall { public enum Average { // Rainfall averages are from the internet and for Cleveland, Ohio January (2.72), February (2.34), …

Member Avatar
Member Avatar
+0 forum 9

one of my goals for this year is to learn java, and I found an excuse to get started lately. So over hte last couple of hours I have been reading tutorials and the likes, and started following the advice from this post http://www.daniweb.com/software-development/java/threads/99132/starting-java-java-tutorials-resources-faq As such I am up to this point http://docs.oracle.com/javase/tutorial/java/concepts/QandE/questions.html it suggested I lookeda around and made note of the state/ behaviours of objects surrounding me. As such I noted the only things that jumped out at me , my books and hte tv, which seemed sufficient for the exercise. However, for the tv I am trying …

Member Avatar
Member Avatar
+0 forum 4

<?php mysql_select_db("store"); $t="SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'stoke' AND COLUMN_NAME = 'catogory'"; $q=mysql_query($t); while($r=mysql_fetch_array($q)) { $y=$r['COLUMN_TYPE']; $u=explode("','",substr($y,6,-2)); //print_r($u); ?> <select name="category" > <option value="">Select Category:</option> <?php foreach($u as $option) { print("<option>$option</option> "); } ?> </select> <?php } ?>

Member Avatar
+0 forum 0

I need to know which of these three copies of code is considered best. I also need to which one is more efficient memory wise and which is more efficient time wise. Thanks: enums [CODE]enum MyEnum{EnumTypeOne=1,EnumTypeTwo=2,EnumTypeThree=4,EnumTypeFour=8};[/CODE] macros [CODE]#define EnumTypeOne 1 #define EnumTypeTwo 2 #define EnumTypeThree 4 #define EnumTypeFour 8 typedef char MyEnum;[/CODE] constants [CODE]const char EnumTypeOne=1; const char EnumTypeTwo=2; const char EnumTypeThree=4; const char EnumTypeFour=8; typedef char MyEnum;[/CODE]

Member Avatar
Member Avatar
+0 forum 20

I have been working on this for awhile, but I was hoping to get input from someone with more experience. I have to stick with the structure and enum format for the assignment, but I was wondering if anyone had any opinions on the way the high/low temperature sections should be done? Thanks for your help, I appreciate any hints. #include <iostream> #include <string> #include <iomanip> using namespace std; struct WeatherInfo { double rainfall; double highTemp; double lowTemp; }; enum Month {January, February, March, April, May, June, July, August, September, October, November, December}; int main() { const int MONTHS = …

Member Avatar
Member Avatar
+0 forum 1

Hello all, I am trying to get a bunch of sub-keys and values from the registry in vb 2010 and i remember in vb6 this was quite easy. Can anyone share code to help? Or a link where I can go? I've been searching for nearly 8 hours on line and can't find anything I can use. The microsoft sites don't really help and most of the articles I find are for vb 7, or vb 6. Any help would be appreciated. ./x86

Member Avatar
Member Avatar
+0 forum 7

Hello guys, so I am facing a problem to understand the following.. Creating a GUI based program that has a user control box that contains a list of images of a 52 cards deck, the cards are based on an enum actually 2 enums one for the rank and one for the suit but i can choose the rank and the suit then hit flip and it should show the image of the card.. Now I have the list of images imported as a recourse, but i dont know how to set the images to the enums and how to …

Member Avatar
Member Avatar
+0 forum 1

I have a warning that I can;t get rid of: Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated. I am pretty sure it is becasue I have not dimentioned the variable but how do you dimention an IO.memorystream. Here is the code: Photograph1.Image = Photograph1.Image.FromStream(New IO.MemoryStream(arr)) Any help would be greatfull. The programms runs and works, its just got those annoying warnings.

Member Avatar
Member Avatar
+0 forum 5

Hello all. For my project I have to create a snack machine with mints and cookies. So far I have gotten an array of cookies with the code below. However an interesting problem I'm having is my output: OATMEAL cookie LEMON cookie null CHOCOLATE_CHIP cookie OATMEAL cookie LEMON cookie null This is the output that I am receiving and repeats for 60 cookie elements. I have no idea how a null element snuck in there. There are only 3 values in the enum class. If anyone could help me point out the problem I would very much appreciate it. Thank …

Member Avatar
Member Avatar
+0 forum 6

Hi, I have to write a program that plays out a whole game of the card game WAR. I have to create a bunch of classes that go along with some pre written classes so right now im trying to start out small and work my way up. We are given two enum classes of Rank and Suit which look like... public enum Suit { /** * The suit CLUBS */ CLUBS('c', "Clubs"), /** * The suit DIAMONDS */ DIAMONDS('d', "Diamonds"), /** * The suit HEARTS */ HEARTS('h', "Hearts"), /** * The suit SPADES */ SPADES('s', "Spades"); public enum Rank …

Member Avatar
Member Avatar
+0 forum 2

i have a problem. i have a table that has one column that should accept one of a set of defined values. i know in MySQL i use the following command to create the table: CREATE TABLE tblstudents ( studentID int( 8 ) UNSIGNED NOT NULL AUTO_INCREMENT, lastName VARCHAR( 20 ) NOT NULL, initial CHAR( 1 ), firstName VARCHAR( 20 ) NOT NULL, gender ENUM( 'Male', 'Female' ) NOT NULL, PRIMARY KEY studentID ( studentID ) ) what command do i use in SQL Server?

Member Avatar
Member Avatar
+0 forum 3

Good Afternoon, I'm having trouble with loops that deal with enumeration. So far I have this code #include <iostream> #include <fstream> #include <string> #include <cstring> #include <cmath> #include <cstdlib> #include <iomanip> using namespace std; int main( ) { //enumerate type definition enum weekDays {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday,Sunday}; //variable declarations weekDays myDays; //to deal with weekDays datatype string day; //C++ string object, to get the day char anotherDay[50]; //C-string var, to get the day as a C-string char choice, //for choice of C++ strings or C-string; option; //a flag to stop the loop //loop foevever to play the program …

Member Avatar
Member Avatar
+0 forum 10

Im trying to create a deck of cards using enums. I already have my enum declared, but I'm stuck in how exactly to create the deck of cards using a boolean array. So far i tried to initialize my constructor, but I don't know what direction to take now. Any help would be greatly appreciated it. Thank you. package Cards; //Class to represent a standard Deck of 52 Playing-Cards // The following functionality is provided // Default Constructor - creates a complete deck of cards // shuffle() - collects all 52 cards into the deck // deal() - returns a …

Member Avatar
Member Avatar
+0 forum 6

Hola code gurus, I’m wondering if there’s a way to use a string to access a specific item in a matrix of int[X]. I have a program which uses enums as iterators to reference a large amount of data. To select an item in the matrix, the user will enter a string, which is also an enum, which also must serve as an iterator for something in the matrix. Here is a toybox example: #include <iostream> #include <string> using namespace std; enum NyNumbers { First, Second, Third, Forth, LAST_VALUE }; int main(int argc, char* argv[]) { int Matrix[LAST_VALUE] = { …

Member Avatar
Member Avatar
+0 forum 3

I'm working on a *soap message *to send to a client system. I must use the client's predefined data types specified on their soap to send my message. Theres alot of arrays and enumerators used and my code gives the following error: > Error 1 Cannot implicitly convert type 'UpdateRatePs._Default.Rate.AvailAppType' to 'UpdateRatePs.IService.AvailAppType?'. > An explicit conversion exists (are you missing a cast?) Upon investigation of the error I found that it is basically telling me that the data types in my code and the webservice are different but I'm not able to figure out how or where the discrepnacy lies …

Member Avatar
Member Avatar
+0 forum 1

hi can u ppl help me on this. can i use multiple enums in a single c program, if so is there any constrain on it? [CODE]enum pattern1 {red, green, yellow} pt1; enum pattern2 {orange, blue, black} p2; enum pattern3 {white, grey, violet} p3;[/CODE] is this possible????

Member Avatar
Member Avatar
+0 forum 2

I'm studying enumeration at the minute and i've a quick question. In the following code using enum, are you limited to ouputting the sequence number of the possible values, or can you use the enum operator to output the text "green"? [CODE] #include <iostream> #include <sstream> #include <fstream> #include "conio.h" using namespace std; int main() { enum colour {red, green, blue}; colour favourite; favourite = green; cout << favourite; _getch(); }[/CODE]

Member Avatar
Member Avatar
+0 forum 5

I am making a simple blackjack game. I have now made the deck which i can draw cards from. But I don't know how to get the values from each card so that i can add them together. I have a card class named Kort with the enum: [CODE]public enum KortVerdi { To, Tre, Fire, Fem, Seks, Sju, Åtte, Ni, Ti, Knekt, Dame, Konge, Ess }; public enum KortFarge { Hjerter, Kløver, Ruter, Spar };[/CODE] And when i draw two cards with my draw method from my main i would like to get the values of the two cards so …

Member Avatar
Member Avatar
+0 forum 5

Holler fellow programmers I have an error that's been bugging me for almost a day now: I keep getting 14 of this error: class, interface, or enum expected Yes, 14 different exact same error message basically for every line of code in the inputGetter method below. Can someone please help... I believe it's a pretty easy solution (maybe)... but I can't find it anywhere. Thanks in advance. [CODE] import java.io.*; import java.util.*; import java.lang.*; public class Driver { public static void main (String[] args) throws IOException { int row = 6; int col = 2; double[][] array = new double[rows][cols]; …

Member Avatar
Member Avatar
+0 forum 3

Good day y'all.. I was never introduced properly to PHP so I come here a lot to seek for help. xd anyways, I have a problem at the moment.. I can't set my enum values properly.. This is how it was added to a table named "joke": [CODE]ALTER TABLE joke ADD COLUMN visible ENUM('NO', 'YES') NOT NULL;[/CODE] jokes.html.php: [CODE]<?php foreach ($jokes as $joke): ?> <form action="?" method="post"> <input type="hidden" name="id" value="<?php htmlout($joke['id']); ?>"/> <select name="visible" id="visible"><br /> <option value="">...</option><br /> <option value="'YES'">Yes</option><br /> <option value="'NO'">No</option><br /> </select> <input type="submit" name="action" value="Set"/> </form>[/CODE] index.php: [CODE]if (isset($_POST['action']) and $_POST['action'] == 'Set') { …

Member Avatar
Member Avatar
+0 forum 1

After a few months of learning and practicing C++ with the book C++ Primer Plus through Chapter 7, I decided to do myself a little simple program. I started with the decision to try splitting my program into multiple files, and I decided to collect all shared declarations/definitions (*) into header files, and that is where the problem started. The first header file created (let's call it headerFile.h), the one I'm working on, has declarations/definitions like these: [CODE]enum QUALITY {QUALITY_1, QUALITY_2, QUALITY_3}; enum QUANTITY {QUANTITY_1, QUANTITY_2, QUANTITY_3, QUANTITY_4}; struct myStruct { int myInt; int myOtherInt1, myOtherInt2; QUALITY myQuality; QUANTITY myQuantity; …

Member Avatar
Member Avatar
+0 forum 5

Hello, I'm a student working on my first hands-on assignment. One of the questions is this: Q4: Write a program that converts a user input temperature from degree Celsius to Fahrenheit or Fahrenheit to Celsius using: C = 5 (F -32)/9 or F = 9C/5 + 32 The user must input temperature with a ‘c’ or ‘f’ (case insensitive) after the number and the program should output the corresponding value. If any other letter, is used, print an error. [10] This is what I have so far, but it's returning 7 errors - one of them being "enum types must …

Member Avatar
Member Avatar
+0 forum 3

Hello, I'm a beginner in these to programming language. Here I want to know how to display the actual value of variable of enum holds. Like this in C++: [code] #include <iostream> #include <conio.h> using namespace std; int main(void) { enum Difficulty { Low = 1, Medium, High }; Difficulty myDiff = High; cout << "Difficulty: " << myDiff << endl; //it displays the value is 3 _getch(); }[/B] [/code] but in C#: [code] using System; public enum Difficulty : byte { Low = 1, Medium, High } class enumProgram { public static void Main(string[] args) { Difficulty myDiff = …

Member Avatar
Member Avatar
+0 forum 2

Hello all, I am enrolled in an intro to C++ class, and I need some help on our final program. Any suggestions are greatly appreciated, as I am quite new to this please don't criticize. Our program requirements require us to receive a command (I.E. delete) input as an array of characters, null-byte terminated. This input must be converted to all caps because the function should accept text of any case. The function must then return the matching pre-defined enum command value. We are not allowed to use strings, and should instead use strlen, strcpy, and strcmp. Any ideas? Here …

Member Avatar
Member Avatar
+0 forum 1

The End.