Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Classe Program//
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication2
- {
- class Program
- {
- static void Main(string[] args)
- {
- Pessoa p1 = new Pessoa("João" ,20);
- while (true)
- {
- Console.Clear();
- Console.WriteLine("Nome: " + p1.nome + " Idade: " + p1.Idade);
- Console.WriteLine("Para fazer aniverssário digite 1");
- Console.WriteLine("Para Sair digite <<Qualquer tecla>>");
- int op = int.Parse(Console.ReadLine());
- if (op==1)
- {
- p1.FazerAniverssario();
- }else{
- //Console.WriteLine("Opção invalida.");
- break;
- }
- }
- Console.ReadLine();
- }
- }
- }
- //Classe Pessoa//
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication2
- {
- class Pessoa
- {
- public int Idade { get; set; }
- public string nome { get; set; }
- public Pessoa(string nome, int idade){
- this.nome = nome;
- this.Idade = idade;
- }
- //Metodo void//
- public void FazerAniverssario(){
- this.Idade++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement