Created
February 4, 2017 03:56
-
-
Save naaando/c81d6a8369f01a7d346b34079ae3a660 to your computer and use it in GitHub Desktop.
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 Main { | |
public static int main(string [] argv) { | |
stdout.printf("Bem vindo ao Mercado Paraná!\n"); | |
stdout.printf("O que deseja comprar?\n"); | |
var produtos = new Produtos(); | |
var abacaxi = new Alimento(); | |
abacaxi.set_qtd(20); | |
abacaxi.set_nome("Abacaxi"); // A classe não sabe o proprio nome ;) | |
abacaxi.set_valor(5.23); //reais o kg | |
produtos.poe_alimento(abacaxi); | |
return 0; | |
} | |
} | |
public class Produtos { | |
Alimento alimento; | |
public void poe_alimento(Alimento a) { | |
alimento = a; | |
} | |
public Alimento retorna_alimento() { | |
var alimento = this.alimento; | |
return alimento; | |
} | |
} | |
public class Alimento { | |
protected int qtd; | |
protected string nome; | |
protected double valor; | |
public void set_qtd(int i) { | |
qtd = i; | |
} | |
public void set_nome(string s) { | |
nome = s; | |
} | |
public void set_valor(double f) { | |
valor = f; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment