-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTravel.kt
36 lines (30 loc) · 915 Bytes
/
Travel.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package clases
import java.time.temporal.TemporalAmount
abstract class Travel() {
abstract protected val country: String
abstract protected val city: String
protected val serviceType = "Viaje"
protected var reserved = false
protected var paidAmount = 0
abstract fun quotePrice(numDays: Int)
protected abstract fun getPrice(numDays: Int):Int
fun reserve(numDays: Int){
if(reserved){
println("""¡Ya reservaste ti viaje!",
"Pais: $country",
"Ciudad: $city",
"Precio: $paidAmount".trimMargin()""")
return
}
val amount = getPrice(numDays)
if(amount == 0){
return
}
reserved = true
paidAmount = amount
println("""¡Viaje reservado exitosamente!"
"Pais: $country",
"Ciudad: $city",
"Precio: $paidAmount""")
}
}