public int GetPotencia() { if (Potencia.Trim().Length == 0) { throw new Exception("Potência não informada."); } int valor; if (int.TryParse(Potencia, out valor)) { return(valor); } else { throw new Exception("A potência informada é inválida."); } }
public TimeSpan GetTempo() { if (Potencia.Trim().Length == 0) { throw new TempoNaoInformadoException("O tempo não foi informado."); } TimeSpan valor; if (TimeSpan.TryParse("0:" + Tempo.Trim(), out valor)) { return(valor); } else { throw new Exception("O tempo informado é inválido."); } }