Gitlab@Informatics

Skip to content
Snippets Groups Projects
Commit cd0e24fe authored by 62160052's avatar 62160052
Browse files

Update price in view model

parent a8ce5300
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,8 @@ import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Locale
private const val PRICE_PER_CUPCAKE = 2.00
class OrderViewModel : ViewModel() {
private val _quantity = MutableLiveData<Int>()
val quantity: LiveData<Int> = _quantity
......@@ -26,6 +28,10 @@ class OrderViewModel : ViewModel() {
resetOrder()
}
private fun updatePrice() {
_price.value = (quantity.value ?: 0) * PRICE_PER_CUPCAKE
}
private fun getPickupOptions(): List<String> {
val options = mutableListOf<String>()
val formatter = SimpleDateFormat("E MMM d", Locale.getDefault())
......@@ -47,6 +53,7 @@ class OrderViewModel : ViewModel() {
fun setQuantity(numberCupcakes: Int) {
_quantity.value = numberCupcakes
updatePrice()
}
fun setFlavor(desiredFlavor: String) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment