I have two enums in two different classes (shown below):
enum State {
NOCAR, SOLD, TO_BUY, TOYOTA, HONDA, NISSAN, BMW, MERCEDES, NO_MONEY
}
enum Car {
TOYOTA, HONDA, NISSAN, BMW, MERCEDES
}
as you can see that the State enum contains all the possiblities of the Car enum.
So I want to do something like this:
public void sayHello(Car brand) {
State s = ... // how to convert the brand parameter into the corresponding State enum?
...
...
}
So I want to be able to convert a given Car enum into a State enum in minimal code that is easy to understand. I know I can use a switch but that is a lot of code wastage. So please help me here.