Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. //no animal class, inheritance not important now
  2.         public class Dog{
  3.            
  4.             string name;
  5.            
  6.             void MakeSound()
  7.             {
  8.                 Console.WriteLine("Bark bark");
  9.             }
  10.         }
  11.        
  12.         public class Duck{
  13.            
  14.             string name;
  15.            
  16.             void MakeSound()
  17.             {
  18.                 Console.WriteLine("Quack quack");
  19.             }
  20.         }
  21.        
  22.         public class Cow{
  23.            
  24.             string name;
  25.            
  26.             void MakeSound()
  27.             {
  28.                 Console.WriteLine("Moo moo");
  29.             }
  30.         }
  31.        
  32.         public static void Main(string[] args)
  33.         {
  34.             Dog dog = new Dog("Dogy");
  35.             dog.MakeSound();
  36.            
  37.             Duck duck = new Duck("Ducky");
  38.             duck.MakeSound();
  39.            
  40.             Coew cow = new Cow("Cowy");
  41.             cow.MakeSound();
  42.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement