Advertisement
wingman007

Exercise2bAnimal

Mar 21st, 2017
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Excercise2bAnimals
  8. {
  9.     abstract class Animal : IMakeNoise
  10.     {
  11.         public string Name { get; set; }
  12.         public int Age { get; set; }
  13.  
  14.         public Animal(string name, int age)
  15.         {
  16.             Name = name;
  17.             Age = age;
  18.         }
  19.  
  20.         // 1 variant without defining a method
  21.         //public abstract string MakeNoise();
  22.         public virtual string MakeNoise()
  23.         {
  24.             return String.Format("My name is {0}, I am {1} years old", Name, Age);
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement