Last active
May 6, 2019 01:44
-
-
Save douglasmartins7/4f8c7034ae5832549ec2da3adade877c to your computer and use it in GitHub Desktop.
Ruby
This file contains hidden or 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
class Carro | |
#constructor | |
def initialize nome = "Modelo padrao" | |
@nome = nome | |
end | |
#set | |
def nome=(value) | |
@nome = value | |
end | |
#get | |
def nome | |
@nome | |
end | |
def mostrar marca="Marca padrao" | |
puts "Marca: #{marca} - Modelo: #{nome}" | |
end | |
end | |
carro = Carro.new | |
puts carro.nome="fox" | |
puts carro.nome | |
carro.mostrar marca="wolkswagen" | |
resultado | |
fox | |
fox | |
Marca: wolkswagen - Modelo: fox | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment