Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace CSharp
- {
- class Animal
- {
- public string name;
- public string sound;
- public Animal(){
- String name;
- String sound;
- }
- public Animal(String _name, String _sound){
- name=_name;
- sound=_sound;
- }
- public void Print(){
- Console.WriteLine("Old MacDonald had a farm, E I O E I O,");
- Console.WriteLine("And on his farm he had a " + name +", E I O E I O");
- Console.WriteLine("With a " + sound + " " + sound +" here and a " + sound + " " + sound + " there,");
- Console.WriteLine("Here a " + sound + "," + " there a " + sound + ", ev'rywhere a " + sound + " " + sound);
- Console.WriteLine("Old MacDonald had a farm, E I E I O");
- }
- }
- class MainClass{
- public static void Main(string [] args){
- Animal cow =new Animal("cow","moo");
- Animal dog= new Animal("dog", "aw");
- Animal duck=new Animal("duck", "quack");
- Animal sheep=new Animal("sheep","mee");
- Animal cat=new Animal("cat", "mwao");
- cow.Print();
- Console.WriteLine();
- dog.Print();
- Console.WriteLine();
- duck.Print();
- Console.WriteLine();
- sheep.Print();
- Console.WriteLine();
- cat.Print();
- Console.WriteLine();
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement