On java enum

public enum Shooter{
  AIM{
    @Override
    public void prepare(){
      // Prepare aiming device
    }

    @Override
    public void action(){
      // Moving your weapon
    }
  },

  SHOOT{
    @Override
    public void prepare(){
      // Make sure you are loaded
    }
    
    @Override
    public void action(){
      // Toggle the trigger
    }
  };
  
  protected abstract void prepare();
  protected abstract void action();
  protected void go(){
    prepare();
    action();
  }
}

你可能感兴趣的:(java,Go)