Jump to content

skeleton script


Franimal

Recommended Posts

state is like declare the method?? like int food? int arrows?

 

You'd have to clarify that question..

 

BotState is an enum, a group of definitions/types.  I could give botState parameters; integers, strings, whatever.  I can then create an instance of BotState and set it equal to one of the types of BotState, and later check which it is.

 

An easier example of an enum would be something like:

private enum Planet {
         MARS(), JUPITER(), EARTH(), NEPTUNE();
}

I could then assign values to them like distance from earth or mass and add getter methods to it

private enum Planet {
         MARS(500, 20000), JUPITER(10000, 200000), EARTH(700, 100), NEPTUNE(100000, -500);

         private final double distance;
         private final double mass;

         public Planet(double distance, double mass){
               this.distance = distance;
               this.mass = mass; 
         }
  
         public double mass(){
                return mass;
         }

         public double distance(){
                return distance;
         }

}

This would allow me to make a variable currentPlanet, which I could set to any Planet that exists, earth, mars, whatever, and it would then contain that planets distance and mass, which I could check and use.  

 

I assume that's what you were asking.  :p

  • Like 1
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...