| Author |
add property of type enum to class
|
Suresh Khant
Ranch Hand
Joined: Feb 27, 2010
Posts: 114
|
|
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: 114
|
|
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: 3791
|
|
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:
|
 |
 |
|
|
subject: add property of type enum to class
|
|
|