Пример #1
0
  /**
   * Gets the cellphone sent SMS list.
   *
   * @return the cellphone sent SMS list
   */
  public List<SMSDTO> getCellPhoneMadeSMS() {
    final List<SMSDTO> smsDtoList = new ArrayList<SMSDTO>();

    for (SMS sms : this.getMadeSMS()) {
      smsDtoList.add(new SMSDTO(sms.getCallerID(), sms.getReceiverID(), sms.getMessage()));
    }
    return smsDtoList;
  }
Пример #2
0
  /**
   * Adicionar comunicação realizada. Verifica se há saldo suficiente antes de fazer a comunicação.
   * For this cellphone be able to make a communication it needs to: Be in a compatible mode with
   * the the type of communication Have enough Balance
   *
   * @param sms the made communication
   * @throws NotEnoughBalanceException the not enough balance exception
   * @throws IncompatibleModeException the incompatible mode for communication exception
   */
  @Override
  public void addMadeSMS(SMS sms) throws NotEnoughBalanceException, IncompatibleModeException {
    final boolean ableToCommunicate = getMode().ableToSendSms();
    if (!ableToCommunicate) {
      throw new IncompatibleModeException("Incompatible Mode", this.getOperator().getSeqNumber());
    }

    if (this.getBalance() - sms.getCost() < 0) {
      throw new NotEnoughBalanceException(
          "Erro: Saldo Insuficiente", this.getOperator().getSeqNumber());
    }

    // Ok, update balance and registry sms
    this.setBalance(this.getBalance() - sms.getCost());
    super.addMadeSMS(sms);
    super.setLastComunication(sms);
  }