Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Animal
- {
- public abstract class Animal
- {
- //Attributes
- private String name;
- private int weigth;
- private String sound;
- public String Name { get { return name; } set { name = value; } }
- public int Weigth { get { return weigth; } set { weigth = value; } }
- public String Sound { get { return sound; } set { sound = value; } }
- //Constructors
- public Animal()
- {
- this.Name = "Unnamed";
- this.Weigth = 0;
- this.Sound = "Unknown";
- }
- public Animal(String name, int weigth, String sound)
- {
- this.Name = name;
- this.Weigth = weigth;
- this.Sound = sound;
- }
- //Methodes
- String says()
- {
- return Sound;
- }
- }
- }
- namespace Cow
- {
- public class Cow : Animal.Animal
- {
- public Cow(String Name, int Weigth, String Sound)
- {
- this.Name = Name;
- this.Weigth = Weigth;
- this.Sound = Sound;
- }
- public Cow(String Name, int Weigth)
- {
- this.Name = Name;
- this.Weigth = Weigth;
- this.Sound = "mooo";
- }
- public Cow(String Name)
- {
- this.Name = Name;
- this.Weigth = 0;
- this.Sound = "mooo";
- }
- public Cow()
- {
- this.Name = "Unnamed";
- this.Weigth = 0;
- this.Sound = "mooo";
- }
- }
- }
- namespace Snake
- {
- public class Snake : Animal.Animal
- {
- public Snake(string name, int weigth, string sound) : base(name, weigth, sound)
- {
- sound = "shhh";
- }
- }
- public class Pig : Animal.Animal
- {
- public Pig(string name, int weigth, string sound) : base(name, weigth, sound)
- {
- sound = "oink";
- }
- }
- static void Main(string[] args)
- {
- Cow.Cow animal1 = new Cow.Cow("Bessy", 0, "MOOOOOO");
- Console.WriteLine(animal1.Name + " " + animal1.Weigth + " " + animal1.Sound);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement