For example the context could be to see if a person can enter the club or not being underage or legal.
In an enum class named Age:
package test; public enum Age { Underage(0), Legal(18) int minAge; Age(int minAge) { this.minAge = minAge; } }
If I have another class named Customer:
package test; public class Customer { static Customer customer; static int age; public Customer(int age) { this.age = age; }
Of course there would be input on their age. My question is how could I compare their age to the enum's value/minAge?
e.g. If the customer was 14, I want to compare this to see if they are less than 18(value of Legal enum variable) in an if statement.
I was thinking something like this:
if(customer.age() >= Age.valueOf(minAge(Legal))
Thanks in advance