示例#1
0
        public void CreateLamb_AnimalWithCorrectNameAndSoundIsCreated()
        {
            Lamb lamb = new Lamb();

            Assert.Equal("lamb", lamb.Name);
            Assert.Equal("baa", lamb.Sound);
        }
示例#2
0
static void Main(string[] args)
{
cows cows1 = new cows("senior Elvis(the cows leader)", "moo", " fresh grass", "meat:");
cows cows2 = new cows(" Mrs Molly","moo", "chick fillet", " milk");
cows cows3 = new cows("Bossy","moo", "Maize" ,"cheese");
cows cows4 = new cows("Lovabull","moo","cabbage","leather");
cows cows5 = new cows("Raven","moo", "spinach", "fertilizer");
Console.WriteLine("Welcome to YAMBA's Farm,here are my special cows");
Console.WriteLine(cows1.GetName(), cows1.eatIT(),cows1.aProduce());
Console.WriteLine(cows2.GetName(), cows2.eatIT(),cows2.aProduce());
Console.WriteLine(cows3.GetName(), cows3.eatIT(),cows3.aProduce());
Console.WriteLine(cows4.GetName(), cows4.eatIT(), cows4.aProduce());
Console.WriteLine(cows5.GetName(), cows5.eatIT(), cows5.aProduce());
Console.WriteLine("*******************************************************************************");
Console.WriteLine("We have a variaty of animals like these ones: ");
chicken chicken = new chicken("Jordan", "cluck");
Console.WriteLine(chicken.speakUp());
Rabbit Rabbit = new Rabbit("Gerald", "squeak");
Console.WriteLine(Rabbit.speakUp());
Lamb lamb = new Lamb("Travis", "bleat");
Console.WriteLine(lamb.speakUp());
Turkey Turkey = new Turkey("Siguel", "globble");
Console.WriteLine(Turkey.speakUp());
Parrot Parrot = new Parrot("Brice", "squawk");
Console.WriteLine(Parrot.speakUp());
Console.ReadLine();

}
示例#3
0
 public void RemoveLamb(Lamb lamb)
 {
     if (this.lambSheep.Contains(lamb))
     {
         this.lambSheep.Remove(lamb);
     }
 }
示例#4
0
        static void Main(string[] args)
        {
            User us1 = new User();

            us1.Update += DisplayMessage;   //добавляем обработчик для события
            us1.Info("ПО пользователя 1: Total Commander");
            us1.date = DateTime.Now;
            us1.Message("Добрый день, не забудьте обновить ПО!");


            Console.WriteLine("Введите версию, до которой хотите обновить ПО: ");

            us1.version = Console.ReadLine();
            us1.New(us1.version, us1.date);
            us1.Pass("H32");
            us1.Pass("Pavel1");

            User us2 = new User();

            us2.Update += DisplayMessage;   //добавляем обработчик для события
            us2.Info("ПО пользователя 2: Adobe Photoshop");
            us2.date = DateTime.Today;

            Console.WriteLine("Введите версию, до которой хотите обновить ПО: ");
            us2.version = Console.ReadLine();
            us2.New(us2.version, us2.date);
            us2.Pass("I_am_User_2");

            Console.WriteLine("Введите название отчета: ");

            Lamb   stroke = s => s.Insert(0, "Принято название отчета: "); //присваиваем объекту делегата лямбду
            string doc    = Console.ReadLine();

            Console.WriteLine(stroke(doc));

            us1.Working += Increment;
            us1.TimeWorking(us1.Time);
            us1.TimeWorking(us1.Time);
            us1.TimeWorking(us1.Time);
            us1.Working += Decrement;
            us1.TimeWorking(us1.Time);

            Console.WriteLine("Введите строку!");
            string str = Console.ReadLine();


            //Func
            Func <string, string> newstring = Operation.RemoveStr;

            Console.WriteLine(newstring(str));
            newstring = Operation.ReplaсeStr;
            Console.WriteLine(newstring(str));
            newstring = Operation.ToUpperStr;
            Console.WriteLine(newstring(str));
            newstring = Operation.ToLowerStr;
            Console.WriteLine(newstring(str));
            Console.ReadKey();
        }
示例#5
0
        public void Test_ShallowCopy()
        {
            var sheep   = new Lamb(5, 3, "black");
            var result  = sheep.ShallowCopy();
            var result1 = sheep.ShallowCopy();

            result1.color = "green";
            var expected = new Lamb(5, 3, "black");

            Assert.AreEqual(result.weight, expected.weight);
            Assert.AreEqual(result.height, expected.height);
            Assert.AreEqual(result.color, expected.color);
        }
示例#6
0
        public void Test_DeepCopy()
        {
            var sheep   = new Lamb(5, 3, "black");
            var result  = sheep.DeepCopy();
            var result2 = sheep.DeepCopy();

            result2.weight = 34;
            var expected = new Lamb(5, 3, "black");

            Assert.AreEqual(result.weight, expected.weight);
            Assert.AreEqual(result.height, expected.height);
            Assert.AreEqual(result.color, expected.color);
        }
示例#7
0
    static void Main(string[] args)
    {
        Lamb sheep = new Lamb(5, 3, "black");

        /*var result1 = sheep.ShallowCopy();
         * result1.color = "green";
         *
         * var result2 = sheep.DeepCopy();
         * result2.weight = 34;
         *
         * var copy = sheep;
         * copy.height = 28;*/

        Console.WriteLine(sheep);

        /* Console.WriteLine(result1);
         * Console.WriteLine(result2);
         * Console.WriteLine(copy);*/
    }
示例#8
0
    public Lamb DeepCopy()
    {
        Lamb dolly = new Lamb(this.weight, this.height, this.color);

        return(dolly);
    }
示例#9
0
 public void AddSheep(Lamb lamb)
 {
     this.lambSheep.Add(lamb);
 }