SHARE
TWEET

C# -Data driven

MartinJanevski Mar 26th, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace CSharp
  4. {
  5.     class Animal
  6.     {
  7.        
  8.         public string name;
  9.         public string sound;
  10.        
  11.        
  12.  
  13.         public Animal(){
  14.             String name;
  15.             String sound;
  16.            
  17.         }
  18.         public Animal(String _name, String _sound){
  19.             name=_name;
  20.             sound=_sound;
  21.         }
  22.         public void Print(){
  23.             Console.WriteLine("Old MacDonald had a farm, E I O E I O,");
  24.             Console.WriteLine("And on his farm he had a " + name +", E I O E I O");
  25.             Console.WriteLine("With a "  + sound + " " + sound +" here and a " + sound + " " + sound + " there,");
  26.             Console.WriteLine("Here a " + sound + "," + " there a " + sound + ", ev'rywhere a " + sound + " " + sound);
  27.             Console.WriteLine("Old MacDonald had a farm, E I E I O");
  28.  
  29.  
  30.                    }
  31.        
  32.     }
  33.     class MainClass{
  34.         public static void Main(string [] args){
  35.          
  36.                 Animal cow =new Animal("cow","moo");
  37.                 Animal dog= new Animal("dog", "aw");
  38.                 Animal duck=new Animal("duck", "quack");
  39.                 Animal sheep=new Animal("sheep","mee");
  40.                 Animal cat=new Animal("cat", "mwao");
  41.  
  42.                 cow.Print();
  43.                 Console.WriteLine();
  44.                 dog.Print();
  45.                 Console.WriteLine();
  46.                 duck.Print();
  47.                 Console.WriteLine();
  48.                 sheep.Print();
  49.                 Console.WriteLine();
  50.                 cat.Print();
  51.                 Console.WriteLine();
  52.  
  53.        
  54.             Console.ReadKey();
  55.         }
  56.     }
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top