Ir para conteúdo
  • 0

[Resolvido] Verificar número


RalfGamerBR

Pergunta

7 respostass a esta questão

Posts Recomendados

public boolean isInt(String str)

{

try

{

Integer.parseInt(str);

return true;

}

catch (NumberFormatException e) {}

return false;

}

if (cmd.getName().equalsIgnoreCase("isint"))

{

if(args.length != 1)

{

sender.sendMessage("§c/isint (Numero)");

return true;

}

if(isInt(args[0]))

{

sender.sendMessage("§cUtilize Somente Numeros");

return true;

}

sender.sendMessage("§aAEEEE, Isto e Um Numero Negro");

return true;

}

Link para o comentário
Compartilhar em outros sites


int a = 0;

boolean ehInt = false;

try{

a = Integer.parseInt(<Argumento_Que_O_Player_Deve_Digitar>);

ehInt = true;

}catch (Exception e){}

if(ehInt){

p.sendMessage("Digite um número.");

}

 

 

Editado por Trow_Games
Link para o comentário
Compartilhar em outros sites

public boolean isInt(String str)
  {
    try
    {
      Integer.parseInt(str);
      return true;
    }
    catch (NumberFormatException e) {}
    return false;
  }
if (cmd.getName().equalsIgnoreCase("isint"))
{
    if(args.length != 1)
    {
        sender.sendMessage("§c/isint (Numero)");
        return true;
    }
    if(isInt(args[0]))
    {
        sender.sendMessage("§cUtilize Somente Numeros");
        return true;
    }
    sender.sendMessage("§aAEEEE, Isto e Um Numero Negro");
    return true;
}

vlw assim foi

		if (comando.getName().equalsIgnoreCase("isint"))
		{
		    if(args.length != 1)
		    {
		        sender.sendMessage("§c/isint (Numero)");
		        return true;
		    }
		    if(!isInt(args[0]))
		    {
		        sender.sendMessage("§cUtilize Somente Numeros");
		        return true;
		    }
		    sender.sendMessage("§aAEEEE, Isto e Um Numero Negro");
		    return true;
		}
		return false;
	}
	public boolean isInt(String str)
	  {
	    try
	    {
	      Integer.parseInt(str);
	      return true;
	    }
	    catch (NumberFormatException e) {}
	    return false;
	  }
Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...