Author Topic: Final Draft of all airplanes (new + existing)  (Read 395 times)

patson

  • Administrator
  • Hero Member
  • *****
  • Posts: 915
    • View Profile
Re: Final Draft of all airplanes (new + existing)
« on: February 23, 2020, 11:36:51 am »
I checked the code to see how the changes in airplane models would affect my planes' depreciation and I found the code I copied below. Because of the change in the price of the 96-400s, their current values are going to be depreciated a **** ton more based on the model's new value. This would mean that it's value would eventually reach zero or negative before they are renewed and it'd be possible that we're going to pay much more than list price to renew this plane. Please have a look

Code: [Select]
  def computeDepreciationRate(model : Model, decayRate : Double) = {
    val depreciationRate = (model.price * (decayRate / 100)).toInt
    depreciationRate
  }
 
  def decayAirplanesByAirline(airplanesWithAssignedLink : Map[Airplane, LinkAssignments], owner : Airline) : List[Airplane] = {
        ...
       
        val newCondition = airplane.condition - decayRate
        val depreciationRate = computeDepreciationRate(airplane.model, decayRate)
        val newValue = airplane.value - depreciationRate
       
        updatingAirplanes.append(airplane.copy(condition = newCondition, depreciationRate = depreciationRate, value = newValue))
    }
    updatingAirplanes.toList
  }

Good catch! I will patch the DB and increase the value of those existing airplanes. Many thanks!