This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

add property of type enum to class

 
Suresh Khant
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All ,
I have the following class :

Student.java


I want to add to the above class property for the result which will be 'Pass' or 'Fail' using enum , how i can do that ...
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create a enum, add it to the class and provide methods for accessing it.
 
Suresh Khant
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Wouter Oet for your reply but how to access the enum

i have added the following : is it right ? how i can access the enum , create setter and getter ?


 
Matthew Brown
Bartender
Posts: 4566
8
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're getting a bit confused there. The enum really ought to be separate from the Student class. And more importantly, the type of the property is the enum, not an int. Something like this:
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic