aspose file tools*
The moose likes Beginning Java and the fly likes add property of type enum to class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "add property of type enum to class" Watch "add property of type enum to class" New topic
Author

add property of type enum to class

Suresh Khant
Ranch Hand

Joined: Feb 27, 2010
Posts: 118
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

Joined: Oct 25, 2008
Posts: 2700

Create a enum, add it to the class and provide methods for accessing it.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Suresh Khant
Ranch Hand

Joined: Feb 27, 2010
Posts: 118
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

Joined: Apr 06, 2010
Posts: 4467
    
    8

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:
 
wood burning stoves
 
subject: add property of type enum to class