Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public interface IDog
- {
- string Name {get;}
- string Breed {get;}
- }
- public class Dog: IDog
- {
- public string Name {get;}
- public string Breed {get;}
- public Dog(string name, string breed)
- {
- this.Name = name;
- this.Breed = breed;
- }
- public Dog()
- {
- }
- public override string ToString()
- {
- string s;
- if(this.Breed != null && this.Name != null)
- {
- s = string.Format("The {0} dog {1} said BARK!",this.Breed,this.Name);
- }
- else
- {
- s = null;
- }
- return s;
- }
- }
- public class Program
- {
- public static void Main()
- {
- string breed = "poodle";
- string name = "Angel";
- Dog poodle = new Dog(name,breed);
- Console.WriteLine(poodle);
- Dog shephard = new Dog();
- Console.WriteLine(shephard);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement