• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

C# regarding enum methods

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey everybody I'm new to C# and I'm having a few issues. I'm currently doing an assignment for school and I'm really stuck on this part. I've staring at it and googling things for hours and I'm having any luck. I have included below what I have so far.

The directions aren't that good.

"Create a public enum CharacterState for the 4 image states: Attacking, Defending, Idle, and Dead. Now create a member variable state to hold the character state and a public property State with a get and set. For now, fill in the default behavior of get and set to return/set the value of state."

Any help would be greatly appeciated! Thank you

 
Bartender
Posts: 1381
39
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Generally speaking (and in my own opinion), when dealing with school assignments it's better to keep yourself focused on the relevant task the assignment is about. For example, I presume you tried to provide a different Image for a game character, but that's not necessary for your task.
Worst error in your code is that  you are creating four different enumerations, not a single enumeration with four possibily states.
Instead, you should have a single enumeration type and a private variable to keep track  of character's status.

For example:



Honestly I think you should review C# enum usage.

Hope it helps !
 
Claude Moore
Bartender
Posts: 1381
39
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For JavaRanch moderators: what about moving this thread on C# and .NET forum ?
 
Yeast devil! Back to the oven that baked you! And take this tiny ad too:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic