Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main #7

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package interactor

import model.CityEntity

class GetCitiesHasHighestDifferentRatingApartment(
private val dataSource: CostOfLivingDataSource
) {
fun execute(): CityEntity {

}

fun excludeNull(cityEntity: CityEntity): Boolean {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,18 @@ class GetCitiesNamesForLowestCostByAverageFruitAndVegetables(
}

fun calculateAverageFruitAndVegetables(cityEntity: CityEntity): Float{
val kilos = cityEntity.fruitAndVegetablesPrices
val sumList = listOf(kilos.apples1kg, kilos.banana1kg,
kilos.oranges1kg, kilos.tomato1kg,
kilos.potato1kg, kilos.onion1kg,
kilos.lettuceOneHead)

val kilos = cityEntity.fruitAndVegetablesPrices!!
val totalFruitAndVegetablesPrices = kilos.run {
apples1kg!! + banana1kg!! + oranges1kg!! + tomato1kg!! + potato1kg!! + onion1kg!! + lettuceOneHead!!
}
return totalFruitAndVegetablesPrices / NUMBER_OF_VARIABLES
}

fun AverageFruitAndVegetablesVsAverageSalaries(cityEntity: CityEntity): Float {
return calculateAverageFruitAndVegetables(cityEntity) / cityEntity.averageMonthlyNetSalaryAfterTax!!
}

companion object {
const val NUMBER_OF_VARIABLES = 7
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package interactor

import model.CityEntity
import model.ClothesPrices

class GetFiveCitiesNamesClothesFromFamousBrands(
private val dataSource: CostOfLivingDataSource
) {

fun execute(limit: Int): List<String>{
return dataSource
.getAllCitiesData()
.filter (::excludeNullClothesPrices)
.sortedBy (::getFiveCities)
.take(limit)
.map { it.cityName }
}

fun excludeNullClothesPrices(cityEntity: CityEntity): Boolean{
return cityEntity.clothesPrices != null
}

fun getFiveCities(cityEntity: CityEntity): Float {
return cityEntity.clothesPrices
}
}
Loading