static void Main(string[] args) { Lion objlion = new Lion(); objlion.AnimalSound(); objlion.Eat(); }
public void Lion_has_claws() { Lion lion = new Lion(); Assert.True(lion.Claws); }
public string RegisterAnimal(string type, string name, int energy, int happiness, int playTime) { IAnimal newAnimal = null; switch (type) { case "Lion": newAnimal = new Lion(name, energy, happiness, playTime); break; case "Dog": newAnimal = new Dog(name, energy, happiness, playTime); break; case "Pig": newAnimal = new Pig(name, energy, happiness, playTime); break; case "Cat": newAnimal = new Cat(name, energy, happiness, playTime); break; } hotel.Accommodate(newAnimal); return($"Animal {name} registered successfully"); }
public IAnimal CreateAnimal(string type, string name, int energy, int happiness, int procedureTime) { IAnimal animal = null; switch (type) { case "Cat": animal = new Cat(name, energy, happiness, procedureTime); break; case "Dog": animal = new Dog(name, energy, happiness, procedureTime); break; case "Lion": animal = new Lion(name, energy, happiness, procedureTime); break; case "Pig": animal = new Pig(name, energy, happiness, procedureTime); break; } return(animal); }
public void LionCanInheritSweat() { Lion lion = new Lion(true, 8, 3, "tan", true); string result = lion.Sweat(); Assert.Equal("Carnivores don't sweat", result); }
public void Lion_Eats_Weasel() { Lion eater = new Lion(); Weasel food = new Weasel(); Assert.True(eater.Eat(food)); }
public void LionCanInheritSleep() { Lion lion = new Lion(true, 8, 3, "tan", true); string result = lion.Sleep(); Assert.Equal("I sleep when I'm tired because I'm warm blooded", result); }
static void Main(string[] args) { Mammal one = new Mammal(); one.Move(); Lion lion = new Lion(); lion.Move(); Whale whale = new Whale(); whale.Move(); Human human = new Human(); human.Move(); /* 자식이 부모 타입으로 암시적으로 형변환된 경우 */ /* virtual, override로 선언된 메서드는 다형성이 구현되어 자식의 메서드가 실행됨. */ one = lion; one.Move(); Mammal two = new Human(); two.Move(); }
static void Main(string[] args) { Lion lion = new Lion(); Mammal one = lion; // 부모타입으로 형변환 one.Move(); }
static void Main(string[] args) { Lion lion = new Lion(true, 77); Console.WriteLine(lion.Male); Console.WriteLine(lion.Weight); }
public static void Main(string[] args) { var tiger = new Tiger(100, "Tiger"); var lion = new Lion(200, "Liom"); tiger.Show(); lion.Show(); }
public static void Main(string[] args) { Lion l1 = new Lion("Lion1", 200); Tiger t1 = new Tiger("Tiger1", 100); l1.Show(); t1.Show(); }
public void Lion_is_an_animal_and_a_mammal() { // Arrange Lion lion = new Lion(); // Assert Assert.True(lion is Animal); }
public static void Main(string[] args) { Tiger t1 = new Tiger("tiger", 100); Lion l1 = new Lion("lion", 200); t1.Show(); l1.Show(); }
public void LionsMane() { Lion testLion = new Lion(); string result = testLion.LionMane(); string expected = "Lion's have a really big mane!"; Assert.Equal(expected, result); }
public void LionRoaming() { /// Test that lion roamingexhibits proper behavior Lion lion = new Lion(); string testRoam = "Roaming around in fields with my lioness"; Assert.Equal(testRoam, lion.Roam()); }
public void LionSleeping() { /// Test that lion sleeping exhibits proper behavior Lion lion = new Lion(); string testSleep = "Me sleep."; Assert.Equal(testSleep, lion.Sleeping()); }
public static void Main() { Lion herman = new Lion(); Giraffe zelda = new Giraffe(); Animal[] two = {herman, zelda}; Feed(two); herman.Attack(); }
public void LionInterfaceInheritance() { /// mating Interface set within mammal, inherited Lion lion = new Lion(); string expectedResult = "You and me baby ain't nothing but mamals"; Assert.Equal(expectedResult, lion.Mating()); }
/// <summary> /// Ajouter un lion bébé /// </summary> /// <param name="x"></param> /// <param name="y"></param> public void AjouterBebeLion(int x, int y) { Animal lion = new Lion(x, y, GenererGenreAnimal(), Vieillesse.Bebe, GenererEtatAnimal(), tabAjout, Logique.TypeAnimal.Lion, listeAnimal, hero); lion.Enceinte = Enceinte.Non; listeAnimal.Add(lion); AjoutVisiteur(); }
public static void Main() { Animal herman = new Lion(); Animal zelda = new Giraffe(); Animal don = new Duck(); Animal[] three = {herman, zelda, don}; Feed(three); }
public void WhatASleepingLionSoundLike() { Lion leon = new Lion(); string result = leon.Sleep(); Assert.Contains("ZZZZ slight growl ZZZZ", result); }
public void CanIUseMethodFromInterFace() { Lion mufasa = new Lion(); string circleOfLife = mufasa.Attention(); Assert.Equal("Circle of Life", circleOfLife); }
} // end of class Elephant static void Main(string[] args) { // Collection Object // 한 우리에다가 가둔다 // 이러한 array를 polymorphic container Animal[] arr = new Animal[100]; int n = 0; // 우리에 동물이 하나도 없다 arr[n++] = new Lion("사원"); arr[n++] = new Lion("사투"); arr[n++] = new Lion("사쓰"); arr[n++] = new Rabbit("토일"); arr[n++] = new Rabbit("토이"); arr[n++] = new Rabbit("토삼"); arr[n++] = new Elephant("코돌이"); arr[n++] = new Elephant("코순이"); // dynamic binding // 함수를 호출할 때, 그 레퍼런스의 타입에 의존해서 하는 것이 아니라 // 그 레퍼런스가 가리키는 객체의 종류에 따라서 알아서 호출되는 제도 for (int day = 0; day < 10; day++) { for (int i = 0; i < n; i++) { arr[i].makeSound(); if (arr[i] is Lion) { arr[i].eat(2); // type casting Lion x = (Lion)arr[i]; x.fart(); } else if (arr[i] is Rabbit) { arr[i].eat(7); Rabbit x = (Rabbit)arr[i]; x.dig(); } else if (arr[i] is Elephant) { arr[i].eat(100); Elephant x = (Elephant)arr[i]; x.shootWater(); } // downcasting하기 전에 반드시 해야 하는 것 : RTTi arr[i].sleep(); } } for (int i = 0; i < n; i++) { Console.WriteLine(arr[i]); } }
public void ZeroParameters() { Lion simba = new Lion(); string location = simba.Location; string boundaries = simba.Boundaries; Assert.Equal("World", location); Assert.Equal("Unknown", boundaries); }
public void TestNull() { Lion simba = new Lion("Africa", "Savana"); simba.Boundaries = null; simba.Location = null; Assert.Equal("Africa", simba.Location); Assert.Equal("Savana", simba.Boundaries); }
public void Create() { Lion simba = new Lion("Africa", "Savanna"); string location = simba.Location; string boundaries = simba.Boundaries; Assert.Equal("Africa", location); Assert.Equal("Savanna", boundaries); }
public void WhatIsHabitatForLion() { Lion lion = new Lion(); string where = lion.Habitat; string myGuess = "Land"; Assert.Equal(myGuess, where); }
void Start() { Lion butcher = new Lion(); butcher.Power = 5; Gazelle nextMeal = new Gazelle(); butcher.Attack(nextMeal); }
public void Test1() { Lion Myla = new Lion("Африка", "Саванны"); string location = Myla.Location; string boundaries = Myla.Boundaries; Assert.Equal("Африка", location); Assert.Equal("Саванны", boundaries); }
static void Main(string[] args) { var lion = new Lion(); lion.EatMeat(); var cow = new Cow(); cow.EatSalad(); }
public static void Main(string[] args) { Lion lion = new Lion("", 0); Tiger tiger = new Tiger("", 0); lion.SetMe("lion", 200); tiger.SetMe("tiger", 100); lion.Show(); tiger.Show(); }
static void Main(string[] args) { var mimi = new Cat(); mimi.Owner = "Pehso"; mimi.Name = "Mimi"; var stamat = new Dog("Stamat", "Minka"); stamat.Bark(); Lion koss = new Lion("Koss", 2, 300); koss.Roar(); Bird sparrow = new Bird(); sparrow.Sing(); }
protected override void ExecuteBirthCommand(string[] commandWords) { string organismType = commandWords[1]; string name = null; Point position = default(Point); switch (organismType) { case WolfType: name = commandWords[2]; position = Point.Parse(commandWords[3]); Wolf newWolf = new Wolf(name, position); this.AddOrganism(newWolf); break; case LionType: name = commandWords[2]; position = Point.Parse(commandWords[3]); Lion newLion = new Lion(name, position); this.AddOrganism(newLion); break; case GrassType: position = Point.Parse(commandWords[2]); Grass newGrass = new Grass(position); this.AddOrganism(newGrass); break; case BoarType: name = commandWords[2]; position = Point.Parse(commandWords[3]); Boar newBoar = new Boar(name, position); this.AddOrganism(newBoar); break; case ZombieType: name = commandWords[2]; position = Point.Parse(commandWords[3]); Zombie newZombie = new Zombie(name, position); this.AddOrganism(newZombie); break; default: base.ExecuteBirthCommand(commandWords); break; } }
public void Visit(Lion lion) { Interlocked.Increment(ref this.lions); }
public virtual void Visit(Lion lion) { }
public void CollectionNamesTest() { var a = new MongoRepository<Animal>(); var am = new MongoRepositoryManager<Animal>(); var va = new Dog(); Assert.IsFalse(am.Exists); a.Update(va); Assert.IsTrue(am.Exists); Assert.IsInstanceOfType(a.GetById(va.Id), typeof(Dog)); Assert.AreEqual(am.Name, "AnimalsTest"); Assert.AreEqual(a.CollectionName, "AnimalsTest"); var cl = new MongoRepository<CatLike>(); var clm = new MongoRepositoryManager<CatLike>(); var vcl = new Lion(); Assert.IsFalse(clm.Exists); cl.Update(vcl); Assert.IsTrue(clm.Exists); Assert.IsInstanceOfType(cl.GetById(vcl.Id), typeof(Lion)); Assert.AreEqual(clm.Name, "Catlikes"); Assert.AreEqual(cl.CollectionName, "Catlikes"); var b = new MongoRepository<Bird>(); var bm = new MongoRepositoryManager<Bird>(); var vb = new Bird(); Assert.IsFalse(bm.Exists); b.Update(vb); Assert.IsTrue(bm.Exists); Assert.IsInstanceOfType(b.GetById(vb.Id), typeof(Bird)); Assert.AreEqual(bm.Name, "Birds"); Assert.AreEqual(b.CollectionName, "Birds"); var l = new MongoRepository<Lion>(); var lm = new MongoRepositoryManager<Lion>(); var vl = new Lion(); //Assert.IsFalse(lm.Exists); //Should already exist (created by cl) l.Update(vl); Assert.IsTrue(lm.Exists); Assert.IsInstanceOfType(l.GetById(vl.Id), typeof(Lion)); Assert.AreEqual(lm.Name, "Catlikes"); Assert.AreEqual(l.CollectionName, "Catlikes"); var d = new MongoRepository<Dog>(); var dm = new MongoRepositoryManager<Dog>(); var vd = new Dog(); //Assert.IsFalse(dm.Exists); d.Update(vd); Assert.IsTrue(dm.Exists); Assert.IsInstanceOfType(d.GetById(vd.Id), typeof(Dog)); Assert.AreEqual(dm.Name, "AnimalsTest"); Assert.AreEqual(d.CollectionName, "AnimalsTest"); var m = new MongoRepository<Bird>(); var mm = new MongoRepositoryManager<Bird>(); var vm = new Macaw(); //Assert.IsFalse(mm.Exists); m.Update(vm); Assert.IsTrue(mm.Exists); Assert.IsInstanceOfType(m.GetById(vm.Id), typeof(Macaw)); Assert.AreEqual(mm.Name, "Birds"); Assert.AreEqual(m.CollectionName, "Birds"); var w = new MongoRepository<Whale>(); var wm = new MongoRepositoryManager<Whale>(); var vw = new Whale(); Assert.IsFalse(wm.Exists); w.Update(vw); Assert.IsTrue(wm.Exists); Assert.IsInstanceOfType(w.GetById(vw.Id), typeof(Whale)); Assert.AreEqual(wm.Name, "Whale"); Assert.AreEqual(w.CollectionName, "Whale"); }
void Awake() { instance = this; }
static void Main() { Lion Simba = new Lion(); Simba.Move(); }