public void SlothSweatOverride() { Sloth sloth = new Sloth(500, "slow", 10, "grey"); string result = sloth.Sweat(); Assert.Equal("I'm a sloth and we can't sweat", result); }
public void TestMethod1() { Animal firstAnimal = new Animal(); firstAnimal.LegCount = 4; Sloth sloth = new Sloth(); sloth.LegCount = 4; Console.WriteLine(sloth.IsSlow); Cat baseCat = new Cat(); baseCat.MakeSound(); TabbyCat tabby = new TabbyCat(); Liger liger = new Liger(); List <Animal> listOfAnimals = new List <Animal>(); listOfAnimals.Add(baseCat); listOfAnimals.Add(tabby); listOfAnimals.Add(liger); listOfAnimals.Add(sloth); foreach (Animal animal in listOfAnimals) { if (animal is Cat) { Cat cat = (Cat)animal; cat.MakeSound(); } } }
/// <summary> /// /// </summary> /// <param name="bits"></param> /// <param name="vrfSig"></param> /// <param name="nonce"></param> /// <returns></returns> public VerifyResult VerifySloth(uint bits, byte[] vrfSig, byte[] nonce) { Guard.Argument(bits, nameof(bits)).NotNegative().NotZero(); Guard.Argument(vrfSig, nameof(vrfSig)).NotNull().MaxCount(32); Guard.Argument(nonce, nameof(nonce)).NotNull().MaxCount(77); var verifySloth = false; try { var ct = new CancellationTokenSource(TimeSpan.FromSeconds(1)).Token; var sloth = new Sloth(ct); var x = System.Numerics.BigInteger.Parse(vrfSig.ByteToHex(), NumberStyles.AllowHexSpecifier); var y = System.Numerics.BigInteger.Parse(nonce.ToStr()); if (x.Sign <= 0) { x = -x; } verifySloth = sloth.Verify(bits, x, y); } catch (Exception ex) { _logger.Here().Fatal(ex, "Unable to verify the delay function"); } return(verifySloth ? VerifyResult.Succeed : VerifyResult.UnableToVerify); }
private void SpawnEnemy() { if (timeSinceLastSpawn < 5) { timeSinceLastSpawn = 0; if (totalEnemyCount < maxEnemyCount) { for (int i = 0; i < maxEnemyCount; i++) { int enemy_type = r.Next(3); Enemy e = null; var ePosition = new Vector2(r.Next(graphics.PreferredBackBufferWidth + 100, 1500), graphics.PreferredBackBufferHeight - 200); switch (enemy_type) { case 0: e = new Zombie(zombieTexture, ePosition, 10); break; case 1: e = new Stark(starkTexture, ePosition, 50); break; case 2: e = new Sloth(slothTexture, ePosition, 80); break; } enemy.Add(e); totalEnemyCount++; } } } }
public void SlothCanInheritSleep() { Sloth sloth = new Sloth(500, "slow", 10, "grey"); string result = sloth.Sleep(); Assert.Equal("I sleep when I'm tired because I'm warm blooded", result); }
public void AnimalTest() { //Animal animal = new Animal(); Sloth sloth = new Sloth(); Console.WriteLine(sloth.IsSlow); sloth.Move(); sloth.SayFurColor(); }
static void Main(string[] args) { Crocodile crocodile = new Crocodile("large", true, 4, "green"); Horse horse = new Horse(6, true, 8, "yellow"); GrizzlyBear grizzly = new GrizzlyBear(true, 1000, 6, "brown", true); Lion lion = new Lion(true, 8, 3, "tan", true); Sloth sloth = new Sloth(500, "slow", 10, "grey"); Snake cobra = new Snake(11, "highly venomous", 3, "black"); crocodile.Sleep(); grizzly.Sleep(); horse.Sweat(); lion.Sweat(); }
static void Main(string[] args) { Sloth latte = new Sloth(); latte.HasFur = true; latte.NumberOfToes = 2; Dog fiesta = new Dog(); fiesta.Breed = "Yellow Lab"; fiesta.NumberOfLegs = 4; Console.WriteLine($"{latte.HasFur} {fiesta.Breed} {fiesta.GetMad()} {latte.StateType()}"); }
public void AnimalTests() { //Animal animal = new Animal(); Sloth sloth = new Sloth(); Console.WriteLine(sloth.IsSlow); sloth.Move(); sloth.SayFurColor(); Axolotl axolotl = new Axolotl(); Console.WriteLine(axolotl.IsCute); axolotl.Move(); axolotl.SayFurColor(); //axolotl.NumberOfLegs(4); }
public void AnimalTests() { // Animal animal = new Animal(); Sloth sloth = new Sloth(); Console.WriteLine(sloth.IsSlow); sloth.Move(); sloth.HasFur = true; Console.WriteLine(sloth.HasFur); sloth.SayFurColor(); Frog frog = new Frog(); Console.WriteLine(frog.CanJump); Console.WriteLine(frog.HasFur); frog.frogColor = FrogColor.Green; Console.WriteLine(frog.frogColor); }
public void TestMethod1() { Animal firstAnimal = new Animal(); firstAnimal.LegCount = 4; Sloth sloth = new Sloth(); sloth.LegCount = 4; Console.WriteLine(sloth.IsSlow); Cat baseCat = new Cat(); baseCat.MakeSound(); Tabbycat tabby = new Tabbycat(); Liger liger = new Liger(); List <Animal> listOfAnimals = new List <Animal>(); listOfAnimals.Add(baseCat); listOfAnimals.Add(tabby); listOfAnimals.Add(liger); listOfAnimals.Add(sloth); foreach (Animal animal in listOfAnimals) { //if (animal.GetType() == typeof(Cat)) if (animal is Cat) { Cat cat = (Cat)animal; //casting- making a cat into animal,keeping animal features but still be a cat cat.MakeSound(); // break point-to check is the new code works } } }
public void SlothCanOverrideNumberOfLegs() { Sloth sloth = new Sloth(500, "slow", 10, "grey"); Assert.Equal(2, sloth.NumberOfLegs); }
public void TestMethod1() { Animal firstAnimal = new Animal(); firstAnimal.LegCount = 4; //cannot access sloth props, only its own Sloth sloth = new Sloth(); sloth.LegCount = 4; //CAN access animal props and its own bool value = sloth.IsSlow; //cant declare, must set to variable as it already has a unchanging value Megatherium giantSloth = new Megatherium(); giantSloth.HasTail = false; giantSloth.IsExtinct = true; Cat firstCat = new Cat(); firstCat.MakeSound(); //Meow Liger liger = new Liger(); liger.MakeSound(); //hover shows Liger.MakeSound only, not Cat.MakeSound Cheetah chee = new Cheetah(); chee.MakeSound(); //Purr. //chee is purr here, but not below as a Cat type List <Cat> catList = new List <Cat>(); //works with Animal too, but not Sloths catList.Add(firstCat); catList.Add(liger); catList.Add(chee); //works, happy List <Animal> animalList = new List <Animal>(); //works with cats, and sloths animalList.Add(firstCat); animalList.Add(liger); animalList.Add(chee); animalList.Add(giantSloth); foreach (Animal animal in animalList) { //cant call MakeSound() because not all animals have MakeSound //can only call Animal properties, not children properties } //foreach(Cat animal in animalList) //doesnt work, gets stuck at non-Cats //{ // animal.MakeSound(); //} foreach (Animal animal in animalList) { //if(animal.GetType() == typeof(Cat)) //Must be Cat type! Liger and Cheetah types wont count as Cat! and skips if (animal is Cat) //works with Cat and children of Cat (ie Liger and Cheetah) but not Sloth etc { //casting yay! Cat cat = (Cat)animal; //cant do above if type isnt already Cat (ex. sloths) //if using (animal is Cat), casting still retains Liger as Liger, etc cat.MakeSound(); //so cat meows and liger still roars //Cheetah didnt purr, because it called original MakeSound, not new MakeSound //new made method unrelated to original MakeSound; } } }