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); }
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); }