コード例 #1
0
ファイル: Anacom.java プロジェクト: hugocore/ANA.COM
  public void endDestinationVoiceCall(
      String sourcePhoneNumber, String destinationPhoneNumber, int duration) {

    if (duration < 0) throw new InvalidDurationException(sourcePhoneNumber, destinationPhoneNumber);

    Phone destinationPhone = getPhone(destinationPhoneNumber);

    Voice activeCommunication =
        (Voice)
            destinationPhone.checkActiveCommunication(
                sourcePhoneNumber, destinationPhoneNumber, AnacomData.CommunicationType.VOICE);
    activeCommunication.setDuration(duration);

    destinationPhone.endReceivedVoiceCall(activeCommunication);
  }
コード例 #2
0
ファイル: Anacom.java プロジェクト: hugocore/ANA.COM
  public void endSourceVoiceCall(
      String sourcePhoneNumber, String destinationPhoneNumber, int duration) {
    if (duration < 0) throw new InvalidDurationException(sourcePhoneNumber, destinationPhoneNumber);

    Phone sourcePhone = getPhone(sourcePhoneNumber);

    Voice activeCommunication =
        (Voice)
            sourcePhone.checkActiveCommunication(
                sourcePhoneNumber, destinationPhoneNumber, AnacomData.CommunicationType.VOICE);

    boolean sameOperator = sameOperator(sourcePhoneNumber, destinationPhoneNumber);
    int cost = sourcePhone.getOperator().getPlan().calcCostVoice(duration, sameOperator);

    sourcePhone.decreaseBalanceBy(cost);

    activeCommunication.setCost(cost);
    activeCommunication.setDuration(duration);

    sourcePhone.endSentVoiceCall(activeCommunication);
  }