static void Main(string[] args) { int convertingChartToInt = 'A'; // Valid - Covert Chart to int and store it in this variable. int covertDecimalToString = 5.0m; // Invalid - Convert Decimal to String and Store it in this variable. ICollection <String> covertListToICollection = new List <string>(); // Valid List<T> Implements ICollection<T> List <Animal> animals = new List <Animal>(); List <Dog> myDogs = new List <Dog>(); Animal myOstrichAsAnimal = new Ostrich(); Animal myDogAsAnimal = new Dog(); Dog myDogAsDog = new Dog(); myOstrichAsAnimal.BuryHeadInGround(); // Will not Compile (myOstrichAsAnimal as Ostrich).BuryHeadInGround(); // Will Compile myDogAsAnimal.Bark(); // Will Not Compile myDogAsDog.Bark(); // Will Compile AdapotAnimal(myOstrichAsAnimal); // Will Compile animals.Add(myOstrichAsAnimal); // Will Compile animals.Add(myDogAsAnimal); // Will Compile animals.Add(myDogAsDog); // Will Compile FeedAnimals(animals); // Will Compile }
public static void Main(string[] args) { /* * IManager accountingVP = new CEO(); * * accountingVP.FirstName = "Emma"; * accountingVP.LastName = "Stone"; * accountingVP.CalculatePerHourRate(4); * * IManaged emp = new Manager(); * * emp.FirstName = "Tim"; * emp.LastName = "Corey"; * emp.AssignManager(accountingVP); * emp.CalculatePerHourRate(2); * * Console.WriteLine($"{ emp.FirstName }'s salary is ${ emp.Salary }/hour."); * * Console.ReadLine();*/ List <Bird> birds = new List <Bird>(); Bird duck = new Duck(); Bird ostrich = new Ostrich(); birds.Add(duck); birds.Add(ostrich); birds.ForEach(b => b.Fly()); }
public void NotifyMoved(object sender, int e) { Ostrich o = sender as Ostrich; Canvas.SetTop(this, o.coords.y); Canvas.SetLeft(this, o.coords.x); }
static void Main(string[] args) { Duck link = new Duck(1, 1); link.output(); link.Action(); link.Eat(); // Console.ReadKey(); Console.WriteLine("************************************************"); Ostrich link1 = new Ostrich(101.1, 101.1); link1.Display(); link1.Eat(); // Console.ReadKey(); Console.WriteLine("************************************************"); Dog link2 = new Dog(3, 3); link2.Action(); link2.Eat(); link2.Output(); Console.WriteLine("************************************************"); Cat link3 = new Cat(3, 3); link3.Action(); link3.Eat(); link3.Output(); Console.ReadKey(); }
public void TigerCanHuntOstrich() { Tiger tiger = new Tiger(); Ostrich mon = new Ostrich(); Assert.Equal("Ostrich", tiger.Hunt(mon)); }
public static void DoSomething(Animal x) { Ostrich y = x as Ostrich; if (y != null) { y.Sprint(); } }
static void Main(string[] args) { /// **** S letter Example **** FileHandler1 fHandler = new FileHandler1(); fHandler.Delete("Example.txt"); FileHandler2 fHandler2 = new FileHandler2(); fHandler.Delete("Example.txt"); /// **** O letter Example **** Logger1 logger = new Logger1(); logger.Log("[ERROR] Print failed"); ErrorLogger2 logger2 = new ErrorLogger2(); logger2.Log("[ERROR] Print failed"); /// **** L letter Example **** Duck duck1 = new Duck(); duck1.Fly(); Ostrich ostrich1 = new Ostrich(); ostrich1.Fly(); Duck2 duck2 = new Duck2(); duck2.Fly(); duck2.GetWeight(); Ostrich2 ostrich2 = new Ostrich2(); ostrich2.GetWeight(); /// **** I letter Example **** // Just interfaces, maybe show later if I'm free and in mood :D /// **** O letter Example **** FileHandler3 fHandler3 = new FileHandler3(); fHandler3.Delete("Example.txt"); FileHandler4 fHandler4 = new FileHandler4(); fHandler4.GetLogger(new Logger2()); fHandler4.Delete("Example.txt"); FileHandler4 fHandler4_1 = new FileHandler4(); fHandler4.GetLogger(new ErrorLogger2()); fHandler4.Delete("Example.txt"); Console.ReadKey(); }
static void Main() { Bird kingfisherBird = new Kingfisher(); Bird ostrichBird = new Ostrich(); kingfisherBird.fly(); // kingfisher can fly. ostrichBird.fly(); // ostrich can fly ?! }
static void Main() { Bird kingfisherBird = new Kingfisher(); Bird ostrichBird = new Ostrich(); kingfisherBird.fly(); // kingfisher can fly. ostrichBird.fly(); // I don't fly rather I run. }
public void SendToBasket(int numToProcess, Farm farm) { var ostrich = new Ostrich(); for (int i = 0; i < numToProcess; i++) { farm.EggGatherer.AddToBasket(ostrich.EggsProduced); farm.EggGatherer.GatheredAnimals(ostrich); } }
public void NewGame(object sender, EventArgs e) { StartGameScreen(sender, e); // Load Map here // Get stage num from controls once the proper screens are implemented Ostrich o = InitiateWorldObject("Ostrich", 720, 450) as Ostrich; control.WorldRef.player = o; playerStateMachine = control.WorldRef.player.stateMachine; /* Comment: Clayton Cockrell * Pterodactyls start spawning at stage 5. stage is set this for testing * purposes. */ int stage = 0; control.WorldRef.stage = stage; int numBuzzards = 0; int numPterodactyls = 0; control.CalculateNumEnemies(control.WorldRef.stage, ref numBuzzards, ref numPterodactyls); InitiateWorldObject("Platform", 100, 300); InitiateWorldObject("Platform", 700, 500); InitiateWorldObject("Platform", 500, 300); InitiateWorldObject("Platform", 950, 200); InitiateWorldObject("Respawn", 700, 100); InitiateWorldObject("Respawn", 1100, 600); InitiateWorldObject("Respawn", 200, 600); InitiateWorldObject("Base", 375, 775); for (int i = 0; i < numBuzzards; i++) { InitiateWorldObject("Buzzard", 100, 300); } for (int i = 0; i < numPterodactyls; i++) { InitiateWorldObject("Pterodactyl", 300, 300); } updateTimer = new DispatcherTimer( TimeSpan.FromMilliseconds(5), DispatcherPriority.Render, UpdateTick, Dispatcher.CurrentDispatcher); updateTimer.Start(); }
public void RunQ4() { Bird seaGUll = new Bird("海鸥", 20, "灰色", "沙丁鱼"); Debug.Log(seaGUll.name + "|奔跑速度:" + seaGUll.speed + "|翅膀颜色:" + seaGUll.wingColour + "|喜爱的食物:" + seaGUll.favouriteFood); Bird petrel = new Bird("海燕", 80, "棕色", "小虾"); Debug.Log(petrel.name + "|奔跑速度:" + petrel.speed + "|翅膀颜色:" + petrel.wingColour + "|喜爱的食物:" + petrel.favouriteFood); Ostrich ostrich = new Ostrich("鸵鸟", 30, "褐色", "苹果"); Debug.Log(ostrich.name + "|奔跑速度:" + ostrich.speed + "|翅膀颜色:" + ostrich.wingColour + "|喜爱的食物:" + ostrich.favouriteFood); }
void RunQ4() { /* * 海鸥的飞行速度是20,翅膀为灰色,最喜欢吃的食物是沙丁鱼。 * 海燕的飞行速度是80,翅膀为棕色,最喜欢吃的食物是小虾。 * 鸵鸟的奔跑速度是30,翅膀为褐色,最喜欢吃的食物是苹果。 * */ Seagull seagull = new Seagull(20, "grey", "sardine"); Petrel petrel = new Petrel(80, "brown", "shrimp"); Ostrich ostrich = new Ostrich(30, "brown", "apple"); Debug.Log("海鸥飞行速度" + seagull.flySpeed + " 翅膀颜色" + seagull.wingColor + " 爱吃" + seagull.favoriteFood); Debug.Log("海燕飞行速度" + petrel.flySpeed + " 翅膀颜色" + petrel.wingColor + " 爱吃" + petrel.favoriteFood); Debug.Log("鸵鸟奔跑速度" + ostrich.runSpeed + " 翅膀颜色" + ostrich.wingColor + " 爱吃" + ostrich.favoriteFood); }
static void Main(string[] args) { Console.WriteLine("Welcome to the Zoo!"); Cow cow = new Cow(); BlackBear blackbear = new BlackBear(); PolarBear polarBear = new PolarBear(); Ostrich ostrich = new Ostrich(); Goose goose = new Goose(); Tortise tortise = new Tortise(); Crocodile crocodile = new Crocodile(); Console.WriteLine($"Cow: {cow.PlowField()}"); Console.WriteLine($"Black Bear: {blackbear.ClimbTree()}"); Console.WriteLine($"Polar Bear: {polarBear.Sleep()}"); Console.WriteLine($"Polar Bear: {polarBear.Prey}"); Console.WriteLine($"Polar Bear: {polarBear.HuntingGround()}"); Console.WriteLine($"Ostrich: {ostrich.Sprint()}"); Console.WriteLine($"Ostrich: {ostrich.Race()}"); Console.WriteLine($"Ostrich: When I race, do I wear blinders? {ostrich.WearBlinders}"); Console.WriteLine($"Goose: {goose.Sound()}"); Console.WriteLine($"Tortise: {tortise.HideInShell()}"); Console.WriteLine($"Crocodile: {crocodile.BirdTeethClean()}"); }
public void OstrichCanInheritEat() { Ostrich ostrich = new Ostrich(); Assert.Equal("I like to eat bugs!!!", ostrich.Eat()); }
public void WorldObjectControlFactory(WorldObject worldObject) { string woString = worldObject.ToString(); Image i; switch (woString) { case "Ostrich": Ostrich o = worldObject as Ostrich; i = new OstrichControl(o.imagePath); OstrichControl oC = i as OstrichControl; o.ostrichMoved += oC.NotifyMoved; break; case "Buzzard": Buzzard b = worldObject as Buzzard; i = new BuzzardControl(b.imagePath); BuzzardControl bC = i as BuzzardControl; // Used to update the view with model updates b.BuzzardMoveEvent += bC.NotifyMoved; b.BuzzardStateChange += bC.NotifyState; b.BuzzardDropEgg += bC.NotifyDrop; b.BuzzardDestroyed += bC.NotifyDestroy; // Used to update all enemies in the world //DispatcherTimer moveTimer = new DispatcherTimer(); //moveTimer.Interval = new TimeSpan(0, 0, 0, 0, 33); //moveTimer.Tick += World.Instance.UpdateAllEnemies_Position; //moveTimer.Start(); /* Comment: Clayton Cockrell * The Random object in Buzzard would give the same random number to all the * Buzzard objects if their creation was not halted for a little bit of time. */ Thread.Sleep(20); break; case "Pterodactyl": PterodactylControl pCtrl = new PterodactylControl("Images/Enemy/pterodactyl.fly1"); i = pCtrl; /* Comment: Clayton Cockrell * Pterodactyls spawn after a certain number of minutes. I currently have it set * to 1 minute. (To change, see PTERODACTYL_SPAWN_MINUTES constant in World class) */ World.Instance.SpawnPterodactyl += pCtrl.NotifySpawn; break; case "Egg": Egg e = worldObject as Egg; i = new EggControl(e.imagePath); EggControl eC = i as EggControl; break; case "Platform": Platform pl = worldObject as Platform; i = new PlatformControl(pl.imagePath); PlatformControl pC = i as PlatformControl; break; case "Respawn": Respawn r = worldObject as Respawn; i = new RespawnControl(r.imagePath); RespawnControl rC = i as RespawnControl; break; default: Base ba = worldObject as Base; i = new BaseControl(ba.imagePath); BaseControl baC = i as BaseControl; break; } canvas.Children.Add(i); Canvas.SetTop(i, worldObject.coords.y); Canvas.SetLeft(i, worldObject.coords.x); //Title_Screen(null, EventArgs.Empty); //Finish_HighScores(null, EventArgs.Empty); // called when game end conditions have been met }
public void Create(out ICreature obj) => obj = new Ostrich();
public void OstrichCanRace() { Ostrich ostrich = new Ostrich(); Assert.Equal("I am the fastest bird on Earth!", ostrich.Race()); }
public void OstrichCanSprint() { Ostrich ostrich = new Ostrich(); Assert.Equal("I run really fast!!!", ostrich.Sprint()); }
/// <summary> /// Creates an instance of the zoo class and configures it as the Como Zoo. /// </summary> private void CreateComoZoo() { // Create an instance of the Zoo class. this.comoZoo = new Zoo("Como Zoo", 1000, 4, 0.75m, 15.00m, 3640.25m, new Employee("Sam", 42), new Employee("Flora", 98), 3); // Add money to the animal snack machine. this.comoZoo.AnimalSnackMachine.AddMoney(42.75m); // Define an animal variable. Animal animal; // Create a new Dingo and add him to the list of animals. animal = new Dingo("Dolly", 4, 35.3); animal.MakePregnant(); this.comoZoo.AddAnimal(animal); // Create a new Dingo and add him to the list of animals. animal = new Dingo("Dixie", 3, 33.8); animal.MakePregnant(); this.comoZoo.AddAnimal(animal); // Create a new platypus and add him to the list of animals. animal = new Platypus("Patty", 2, 15.5); animal.MakePregnant(); this.comoZoo.AddAnimal(animal); // Create a new Hummingbird and add him to the list of animals. animal = new Hummingbird("Harold", 1, 0.5); this.comoZoo.AddAnimal(animal); // Create a new chimp and add him to the list of animals. animal = new Chimpanzee("Noah", 12, 500); this.comoZoo.AddAnimal(animal); // Create a new eagle and add him to the list of animals. animal = new Eagle("Tracy", 300, 10); this.comoZoo.AddAnimal(animal); // Create a new kangaroo and add him to the list of animals. animal = new Kangaroo("Jeff", 25, 30); this.comoZoo.AddAnimal(animal); // Create a new ostrich and add him to the list of animals. animal = new Ostrich("Jake", 40, 200); this.comoZoo.AddAnimal(animal); // Create a new shark and add him to the list of animals. animal = new Shark("Max", 23, 185); this.comoZoo.AddAnimal(animal); // Create a new squirrel and them to the list. animal = new Squirrel("Matt", 21, 200); this.comoZoo.AddAnimal(animal); // Create a guest. Guest guest = new Guest("Greg", 44, 150.35m, "Brown"); // Add the guest and sell the ticket to the guest. this.comoZoo.AddGuest(guest, this.comoZoo.SellTicket(guest)); // Create a guest. guest = new Guest("Darla", 11, 25.25m, "Salmon"); // Add the guest and sell the ticket to the guest. this.comoZoo.AddGuest(guest, this.comoZoo.SellTicket(guest)); }
/// <summary> /// Updates the visual for Ostrich based on the current state of the object in the model /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void NotifyMoved(object sender, int e) { Ostrich o = sender as Ostrich; Canvas.SetTop(this, o.coords.y); Canvas.SetLeft(this, o.coords.x); if (o.leftDown) { LayoutTransform = new ScaleTransform() { ScaleX = -1 } } ; else if (o.rightDown) { LayoutTransform = new ScaleTransform() { ScaleX = 1 } } ; if (o.stateMachine.Current is StandState) { if (o.leftDown || o.rightDown) { if (currentMove.EndsWith("stand.png")) { currentMove = "Sprites/player_move3.png"; } else if (currentMove.EndsWith("move3.png")) { currentMove = "Sprites/player_move2.png"; } else if (currentMove.EndsWith("move2.png")) { currentMove = "Sprites/player_move1.png"; } else { currentMove = "Sprites/player_stand.png"; } Task.Run(() => { Dispatcher.Invoke(() => Source = new BitmapImage(new Uri(currentMove, UriKind.Relative))); }); } else { Source = new BitmapImage(new Uri(o.imagePath, UriKind.Relative)); } } else if (o.stateMachine.Current is FallState) { Source = new BitmapImage(new Uri("Sprites/player_fly1.png", UriKind.Relative)); } else if (o.stateMachine.Current is SpawnState) { if (o.coords.y > World.Instance.basePlatform.coords.y - 70) { o.coords.y -= 2; } Source = new BitmapImage(new Uri("Sprites/player_respawn.png", UriKind.Relative)); } else if (o.stateMachine.Current is DeadState) { if (currentMove.EndsWith("fly1.png")) { currentMove = "Images/Player/ostrich_fly2.png"; } else { currentMove = "Images/Player/ostrich_fly1.png"; } LayoutTransform = new ScaleTransform() { ScaleX = 1 }; Task.Run(() => { Dispatcher.Invoke(() => Source = new BitmapImage(new Uri(currentMove, UriKind.Relative))); }); } } }
public void OstrichCanBuryHed() { Ostrich ostrich = new Ostrich(); Assert.True(ostrich.BuryHead()); }
public void OstrichCannotFly() { Ostrich ostrich = new Ostrich(); Assert.False(ostrich.fly()); }
public void OstrichCanInheritSound() { Ostrich ostrich = new Ostrich(); Assert.Equal("Wenk! Wenk! Wenk!", ostrich.Sound()); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); //created a new object of Tiger ,Teddy is a Tiger Tiger tiger = new Tiger(); string name = tiger.Speak("Ted"); Console.WriteLine($"Hello,my name is {name}, i am a tiger"); Console.WriteLine("My color is:" + tiger.color); Console.WriteLine($"I have { tiger.legs} legs"); tiger.Eat(); tiger.Sleep(); Console.WriteLine("**************"); //created a panda object Panda panda = new Panda(); panda.name = "Sunshine"; Console.WriteLine($"Hi! I am a panda my name is {panda.name}"); panda.Eat(); panda.Sleep(); Console.WriteLine("**************"); //created a Monkey object Monkey monkey = new Monkey(); monkey.name = "King"; Console.WriteLine($"Hi! I am a monkey my name is {monkey.name}"); monkey.Eat(); monkey.Sleep(); Console.WriteLine("**************"); //created a Tutle object Turtle turtle = new Turtle(); turtle.shell = 1; turtle.name = "Alex"; Console.WriteLine($"Hi I am turtle,my name is {turtle.name} and i have {turtle.shell} shell"); turtle.Eat(); turtle.Move(); Console.WriteLine(turtle.ControlBodyTemperature()); turtle.Sleep(); Console.WriteLine("**************"); //created a Owl object Owl owl = new Owl(); owl.Sleep(); owl.Eat(); owl.sound(); Console.WriteLine("I can fly:" + owl.fly()); Console.WriteLine("**************"); //created a Ostrich object Ostrich ostrich = new Ostrich(); ostrich.Sleep(); ostrich.Eat(); Console.WriteLine("I can fly:" + ostrich.fly()); Console.WriteLine("**************"); Console.WriteLine("**************"); string foodOne = tiger.Hunt(monkey); //string foodTwo=tiger.Hunt(ostrich); //Console.WriteLine($"I can hunt {foodOne} and {foodTwo}"); Console.WriteLine($"I can hunt {foodOne}"); Console.WriteLine("**************"); Console.WriteLine(monkey.Mimic("jump and clap")); }