Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Métodos y Atributos Públicos y Privados en Kotlin (Curso de Kotlin de…
…sde cero [55]) Video: https://youtu.be/zeHg5mgnFAA
- Loading branch information
1 parent
d5e559a
commit 6e69326
Showing
1 changed file
with
28 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,37 @@ | ||
class auto{ | ||
var color="" | ||
var modelo=0 | ||
var marca="" | ||
fun enciende(){ | ||
private var color="" | ||
private var modelo=0 | ||
private var marca="" | ||
private var acceso=false | ||
public fun meterLlave(llave:String){ | ||
if(llave=="123456"){ | ||
acceso=true | ||
println("Tienes acceso al auto") | ||
}else{ | ||
acceso=false | ||
println("No tienes acceso al auto (sonar alarma)") | ||
} | ||
} | ||
public fun mando(accion:String){ | ||
if(acceso==true){ | ||
if(accion=="encender"){ | ||
enciende() | ||
} | ||
}else{ | ||
println("No tienes acceso al auto (sonar alarma)") | ||
} | ||
} | ||
private fun enciende(){ | ||
println("Enciende el auto run run") | ||
} | ||
fun acelera(){ | ||
private fun acelera(){ | ||
println("El auto acelero 10Km/h mas") | ||
} | ||
fun frena(){ | ||
private fun frena(){ | ||
println("El auto freno a 10Km/h menos") | ||
} | ||
} | ||
var vocho1=auto() | ||
vocho1.color="Verde" | ||
vocho1.modelo=1980 | ||
vocho1.marca="Vocho" | ||
println(vocho1.color) | ||
println(vocho1.modelo) | ||
println(vocho1.marca) | ||
vocho1.enciende() | ||
vocho1.acelera() | ||
vocho1.frena() | ||
|
||
var vocho2=auto() | ||
vocho2.color="Azul" | ||
vocho2.modelo=1981 | ||
vocho2.marca="Vocho" | ||
var vocho1=auto() | ||
vocho1.meterLlave("123456") | ||
vocho1.mando("encender") |