Advertisement
plattina

ClasseAnimal(IFBA-LP2)

Aug 26th, 2019
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ReinoAnimal
  4. {  
  5.     class Animal
  6.     {
  7.         public bool Vivo { get; protected set; }
  8.         public float Idade { get; protected set; }
  9.         public float Peso { get; protected set; }
  10.         public string Som { get; protected set; }
  11.         public float Velocidade { get; protected set; }
  12.  
  13.         public void Nasce()
  14.         {
  15.             Vivo = true;
  16.             Idade = 0;
  17.         }
  18.  
  19.         public void Cresce(float tempoDeVida)
  20.         {
  21.             Idade += tempoDeVida;
  22.         }
  23.  
  24.         public Animal Reproduz()
  25.         {
  26.             Animal filho = new Animal();
  27.             filho.Nasce();
  28.             return filho;
  29.         }
  30.  
  31.         public void Morre()
  32.         {
  33.             Vivo = false;
  34.         }
  35.  
  36.         public virtual void Locomove()
  37.         {
  38.             Console.WriteLine("Moveu-se a uma velocidade de " + Velocidade + "KM/h");
  39.         }
  40.  
  41.         public virtual void Comunica()
  42.         {
  43.             Console.WriteLine(Som);
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement