Created
March 30, 2023 17:12
-
-
Save jailsonsf/1e67918ae912c4eec800599fa6a21cc3 to your computer and use it in GitHub Desktop.
Formação Ruby DIO
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
require_relative 'produto' | |
require_relative 'mercado' | |
produto = Produto.new | |
produto.nome = 'Farinha de trigo' | |
produto.preco = 4.0 | |
Mercado.new(produto.nome, produto.preco).comprar | |
livro = Produto.new | |
livro.nome = 'Livro' | |
livro.preco = 30.0 | |
Mercado.new(livro.nome, livro.preco).comprar |
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
class Mercado | |
def initialize(produto, preco) | |
@produto = produto | |
@preco = preco | |
end | |
def comprar | |
puts "Você comprou o produto #{@produto} pelo preco de #{@preco}" | |
end | |
end |
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
class Produto | |
attr_accessor :nome, :preco | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment