Thank for your comments.
I corrected the public for a private member.
"Steve W. Jackson" <stevewjackson@knology.net> a ?crit dans le message de
In article <chfai.25548$ih7.119576@weber.videotron.net>,
"Philippe" <Philippe@Massicotte.com> wrote:
Hi all.
I wrote a method and I want to have only 2 possibility when using
arguments.
In other words, I just want to be able to use 2 type of values.
public class DataAnalyzer {
public enum Mode { YSI, HYPERPRO } //the 2 possible values
//Specify the file type
public Mode mode;
public DataAnalyzer(Mode m) {
mode = m;
}
Here's my main :
DataAnalyzer d = new DataAnalyzer(DataAnalyzer.Mode.YSI);
I want to know if this is a good way to do. I dont like the
"DataAnalyzer.Mode.YSI". Maybe there's a better solution.
Best regards,
Phil
I think it's a good idea.
If you want to use the Mode enum locally, you might want to declare it
as a "public static enum" instead. And you should *not* make the "mode"
member variable public, but private so that it's required to be provided
in the constructor.
If you really don't want the dotted notation, however, you can move the
Mode enum outside of the DataAnalyzer class -- either in the same file
or in a separate one. But IMHO it's better design, if indeed this enum
is only for use with DataAnalyzer, if it's part of the class.
= Steve =
--
Steve W. Jackson
Montgomery, Alabama