public TurkeyAdapter(Turkey turkey) { this.turkey = turkey; }
//TODO: add pub 84, 88 and 95 shit public override void OnDoubleClick(Mobile from) { if (m_UsesRemaining > 0) { Item item = null; switch (Utility.Random(10)) { case 0: item = new SweetPotatoPie(); break; case 1: item = new MashedSweetPotatoes(); break; case 2: item = new BasketOfRolls(); break; case 3: item = new TurkeyPlatter(); break; case 4: BaseCreature bc = new Turkey(true); if (0.10 > Utility.RandomDouble()) { bc.Name = "Mister Gobbles"; } bc.MoveToWorld(from.Location, from.Map); from.SendLocalizedMessage(1153512); //That one's not cooked! break; case 5: new InternalTimer(from); from.Frozen = true; break; case 6: item = new PottedCoffeePlant(); break; case 7: item = new RoastingPigOnASpitDeed(); break; case 8: item = new FormalDiningTableDeed(); break; case 9: item = new BuffetTableDeed(); break; } if (item != null) { if (from.Backpack == null || !from.Backpack.TryDropItem(from, item, false)) { item.MoveToWorld(from.Location, from.Map); } UsesRemaining--; } } }
private void InitAnimals() { Duck donald = new Duck("Donald"); Cat lizy = new Cat("Lizy"); Dog rex = new Dog("Rex"); Horse blackbeauty = new Horse("BlackBeauty"); Turkey freebie = new Turkey("Freebie"); animals.Add(donald); animals.Add(lizy); animals.Add(rex); animals.Add(blackbeauty); animals.Add(freebie); }
public void populate_should_not_change_property_values_not_found_in_the_dictionary() { var item = new Turkey { Name = "Smith" }; context["Age"] = 9; binder.Populate(item, context); item.Name.ShouldEqual("Smith"); item.Age.ShouldEqual(9); }
public void populate_should_not_change_property_values_not_found_in_the_dictionary() { var turkey = new Turkey() { Name = "Smith" }; usingData(x => { x.Model = turkey; x.Data("Age", 9); }); theResultingObject.Name.ShouldEqual("Smith"); theResultingObject.Age.ShouldEqual(9); }
// Use this for initialization void Start() { System.Random rnd = new System.Random(); List <Point> points = new List <Point>(); float offset = (float)(rnd.NextDouble() * 5); foreach (var obj in TurkeyPoints) { float xPosition = obj.transform.position.x; float yPosition = obj.transform.position.y; points.Add(new Point(xPosition - offset, yPosition)); } _turkey = new Turkey(points); jumpPeriod = (float)(rnd.NextDouble() * 5f + 5); TurkeyLateralMove(); }
static void Main(string[] args) { Console.WriteLine("Duck:"); Duck duck = new Duck(new CanFly(), new CanQuack(), new CanSwim());; InfoDuck(duck); Console.WriteLine("\nRubber Duck:"); Duck rubberDuck = new Duck(new CantFly(), new PiskQuack(), new CanSwim()); InfoDuck(rubberDuck); Console.WriteLine("\nTurkey:"); Turkey turkey = new Turkey(new CanCackle(), new CanEat(), new CanSleep()); InfoTurkey(turkey); }
void CollisionWithTurkey() { turkey_list = GameObject.FindGameObjectsWithTag("Turkey"); for (int i = 0; i < turkey_list.Length; i++) { Turkey turkey = turkey_list[i].GetComponent <Turkey>(); for (int j = 0; j < turkey.points.Count; j++) { float distance = Mathf.Sqrt(Mathf.Pow(turkey.points[j].x * turkey.scale + turkey.initiate_point.x - transform.position.x, 2) + Mathf.Pow(turkey.points[j].y * turkey.scale + turkey.initiate_point.y - transform.position.y, 2)); if (distance <= radius) { turkey.HitByCannonball(turkey.origin - transform.position); Destroy(gameObject); } } } }
static void DuckTestDrive() { IDuck duck = new Duck(); var turkey = new Turkey(); IDuck turkeyAdapter = new TurkeyAdapter(turkey); Console.WriteLine("Turkey says........."); turkey.Gobble(); turkey.Fly(); Console.WriteLine("Duck says........."); TestDuck(duck); Console.WriteLine("TurkeyAdapter says........."); TestDuck(turkeyAdapter); Console.ReadLine(); }
static void Adapter() { Console.WriteLine("Duck:"); Adapter.Classes.Duck duck = new Adapter.Classes.Duck(); duck.Quack(); duck.Fly(); Console.WriteLine(); Console.WriteLine("Turkey:"); Turkey turkey = new Turkey(); turkey.Gobble(); turkey.Fly(); Console.WriteLine(); Console.WriteLine("DuckAdapter:"); DuckAdapter duckAdapter = new DuckAdapter(turkey); duckAdapter.Quack(); duckAdapter.Fly(); }
//public class HalfTon : Truck { } // does not compile because Truck is sealed #endregion #region Inheritance & Polymorphism Pt. 1 //static void Main() //{ // IWingedAnimal animal = new Bat(); // IWingedAnimal animal2 = new Bird(); // animal.Fly(); //} //public class Person //{ // protected DateTime _dateOfBirth; // public Person() { } // public string Name { get; private set; } // protected Person(string name) // { // Name = name; // } // public DateTime DateOfBirth // { // get { return _dateOfBirth; } // set { _dateOfBirth = value; } // } //} //public class Member : Person //{ // public Member() { } // protected Member(string name) : base(name) { } // public DateTime EffectiveDate { get; set; } //} //public class PolicyHolder : Member //{ // public PolicyHolder(string name, DateTime dateOfBirth) // { // // doesn't compile, inaccessable because _name is private to Person // //_name = name; // // compiles, accessable because _dateOfBirth is protected by Person so all it's child classes can access it. // _dateOfBirth = dateOfBirth; // } // public PolicyHolder(string name) : base(name) { } // public Dependent[] Dependents { get; set; } //} //public class Dependent : Member //{ // public PolicyHolder PolicyHolder { get; set; } //} //public class Animal //{ // public void Eat() // { // Console.WriteLine("Eating yummy food."); // } //} //public interface IWingedAnimal //{ // void Fly(); //} //public interface IMammal //{ // void Breath(); //} //public class Bat : Animal, IWingedAnimal, IMammal //{ // public void Fly() // { // Console.WriteLine("Bat is flying"); // } // public void Breath() // { // Console.WriteLine("Bat is breathing"); // } //} //public class Bird : Animal, IWingedAnimal //{ // public void Fly() // { // Console.WriteLine("Bird is flying"); // } //} #endregion #region Linq //private static readonly int[] Ints1 = { 1, 2, 3, 4, 5, 6 }; //private static readonly int[] Ints2 = { 5, 6, 7, 8, 9, 10 }; //static void Main() //{ // var context = new DataModel(); // //JoinExample(context.People, context.Claims); // //CastExample(context.Cars); // //ConcatExample(); // //UnionExample(); // //IntersectExample(); // //ExceptExample(); // //ContainsExample(); // //ZipExample(); // //DefaultIfEmptyExample(); // //DistinctExample(); // //FirstExample(context.People); // //LastExample(context.People); // //SingleExample(context.People); // //GroupByExample(context); // //GroupJoinExample in Mapper.cs // //SelectExample(context); // ComputingExample(context); // Console.ReadKey(true); //} //private static void ComputingExample(DataModel context) //{ // var result1 = Ints1.Sum(); // var result2 = Ints1.Aggregate((x, y) => x * y); // var result3 = Ints1.Average(); // var result4 = Ints1.Min(); // var result5 = context.Claims.Min(x => x.Amount); // var result6 = context.Claims.Max(x => x.Amount); //} //private static void SelectExample(DataModel context) //{ // var select1 = context.People.Select(x => x.FirstName).ToList(); // var select2 = context.People.Select(x => x.Claims.Where(y => y.Amount > 100)).ToList(); // var select3 = context.People.SelectMany(x => x.Claims.Where(y => y.Amount > 100)).ToList(); // var select4 = context.People.Select(x => new { Name = $"{x.FirstName} {x.LastName}", ClaimsNums = x.Claims.Select(y => y.ClaimNumber) }).ToList(); // var select5 = (from person in context.People // where person.Claims.Count > 2 // select person.FirstName).ToList(); // var select6 = context.People.Where(x => x.Claims.Count > 2).Select(x => x.FirstName).ToList(); //} //private static void ZipExample() //{ // var result = Ints1.Zip(Ints2, (x, y) => x * y); //} //private static void UnionExample() //{ // var result = Ints1.Union(Ints2); //} //private static void SingleExample(ICollection<Person> people) //{ // people.Add(new Person { FirstName = "Steve" }); // //var person1 = people.Single(x => x.FirstName == "Steve"); // var person2 = people.SingleOrDefault(x => x.FirstName == "Matt"); // //var person3 = people.Single(x => x.FirstName == "Matt"); // var person4 = people.Single(x => x.FirstName == "Tony"); //} //private static void JoinExample(ICollection<Person> people, ICollection<Claim> claims) //{ // var results = people.Join(claims, p => p.PersonId, c => c.PersonId, (p, c) => new { Person = p, Claim = c }); //} //private static void IntersectExample() //{ // var result = Ints1.Intersect(Ints2); //} //private static void GroupByExample(DataModel context) //{ // var groupedclaims = context.Claims.GroupBy(x => x.Person).ToList(); // foreach (var groupedclaim in groupedclaims) // { // Console.WriteLine($"{groupedclaim.Key.FirstName} {groupedclaim.Key.LastName} Claims:"); // foreach (var claim in groupedclaim) // { // Console.WriteLine($"{claim.ClaimId} {claim.ClaimDate} {claim.Amount}"); // } // Console.WriteLine(); // } //} //private static void LastExample(ICollection<Person> people) //{ // var lastPerson = people.Last(); // //FirstOrDefault // var nullPerson = people.LastOrDefault(x => x.FirstName == "Matthew"); // var exceptionPerson = people.Last(x => x.FirstName == "Matthew"); //} //private static void FirstExample(ICollection<Person> people) //{ // var firstPerson = people.First(); // //FirstOrDefault // var nullPerson = people.FirstOrDefault(x => x.FirstName == "Matthew"); // var exceptionPerson = people.First(x => x.FirstName == "Matthew"); //} //private static void ExceptExample() //{ // var result = Ints1.Except(Ints2); //} //private static void CastExample(IEnumerable<Vehicle> vehicles) //{ // var cars = vehicles.Cast<Car>(); //} //private static void ConcatExample() //{ // var result = Ints1.Concat(Ints2); //} //private static void ContainsExample() //{ // var result1 = new[] { 1, 2, 3, 4, 5, 6 }.Contains(4); // var result2 = "Hi my name is Steve.".Contains("Steve"); //} //private static void DefaultIfEmptyExample() //{ // var list1 = new List<int>(); // var list2 = list1.DefaultIfEmpty(); // foreach (var i in list1) // { // Console.WriteLine(i); // } // Console.ReadKey(true); // foreach (var i in list2) // { // Console.WriteLine(i); // } //} //private static void DistinctExample() //{ // var list1 = new[] { 1, 2, 3, 3, 3, 4, 5, 5, 6 }; // var list2 = list1.Distinct(); // Console.WriteLine("List1:"); // foreach (var i in list1) // { // Console.WriteLine(i); // } // Console.WriteLine("List2:"); // foreach (var i in list2) // { // Console.WriteLine(i); // } //} #endregion #region Access Modifiers / Misc Keywords //static void Main() //{ //} //static void Main() //{ // Person person = new Person(); // person.Talk(); // person.Move(); // Console.WriteLine(); // Child child = new Child(); // child.Talk(); // child.Move(); // Console.WriteLine(); // Person person2 = new Child(); // person2.Talk(); // person2.Move(); // Console.ReadLine(); //} //public class Person //{ // private string _name; // protected DateTime _dateOfBirth; // public string Name { get { return _name; } set { _name = value; } } // public DateTime DateOfBirth { get { return _dateOfBirth; } set { _dateOfBirth = value; } } // public void Talk() // { // Console.WriteLine("Person Talking"); // } // public virtual void Move() // { // Console.WriteLine("Person moving"); // } //} //public sealed class Developer : Person //{ // public Developer() // { // _dateOfBirth = new DateTime(); // //_name = "Clint Barton"; // } //} //public class RyanClone : Developer //{ // public string MuscleSize { get; set; } = "Huge"; //} //public class Child : Person //{ // public new void Talk() // { // Console.WriteLine("Child Talking"); // } // public override void Move() // { // Console.WriteLine("Child Moving"); // } //} #endregion #region Extention Methods and Operators //public static void Main() //{ // new Person().DisplayPerson(); // var myPerson = new Person(); // myPerson.DisplayPerson(); // var person1 = new Person // { // DateOfBirth = new DateTime(1920, 7, 19) // }; // var person2 = new Person(); // //- operator // Console.WriteLine($"- operator: {person1 - person2}"); // //== operator // Console.WriteLine($"== operator: {person1 == person2}"); // Console.ReadLine(); //} #endregion #region C#6 //static void Main(string[] args) //{ // //String Interpolation // var hawkeye = new Person("Clint", "Barton"); // var fullName = hawkeye.FirstName + " " + hawkeye.LastName; //Old way // var fullName2 = string.Format("{0} {1}", hawkeye.FirstName, hawkeye.LastName); //Old way // var fullName3 = $"{hawkeye.FirstName} {hawkeye.LastName}"; //New way // Console.WriteLine(fullName); // Console.WriteLine(fullName2); // Console.WriteLine(fullName3); // Console.WriteLine(); // //Auto-Implemented Properties // var captain = new Person(); // Console.WriteLine(captain.FirstName); // Console.WriteLine(captain.LastName); // Console.WriteLine(captain.Dob); // Console.WriteLine(); // //using static // WriteLine("using static example"); // WriteLine(); // //Null-Conditional Operator // var ironman = new Person("Tony", "Stark"); // //var ironmanCity = ironman.Address.City; // //var ironmanCity = ironman.Address?.City; // var ironmanCity = ironman.Address?.City ?? "City not found."; // Console.WriteLine(ironmanCity); // Console.WriteLine(); // //nameof // var myExampleVariable = string.Empty; // Console.WriteLine(nameof(myExampleVariable)); // Console.WriteLine(); // //Exception filtering // try // { // //throw new IndexOutOfRangeException("BadIndex"); // //throw new IndexOutOfRangeException(); // throw new ArgumentNullException(); // } // catch (IndexOutOfRangeException ex) when (ex.Message.Equals("BadIndex")) // { // Console.WriteLine("Caught BadIndex"); // } // catch (IndexOutOfRangeException) // { // Console.WriteLine("Caught IndexOutOfRangeException"); // } // catch (Exception) // { // Console.WriteLine("Caught Exception"); // } // Console.WriteLine(); // //Expression-bodied members // Console.WriteLine(ironman.OldFullName); // Console.WriteLine(ironman.NewFullName); // Console.ReadLine(); //} //class Person //{ // public string FirstName { get; } = "Steve"; // public string LastName { get; } = "Rogers"; // public string OldFullName { get { return $"{FirstName} {LastName}"; } } // public string NewFullName => $"{FirstName} {LastName}"; // public DateTime Dob { get; set; } = new DateTime(1920, 7, 4); // public Address Address { get; set; } // public Person() // { // } // public Person(string firstName, string lastName) // { // FirstName = firstName; // LastName = lastName; // } //} //public class Address //{ // public string Street { get; set; } // public string City { get; set; } // public string State { get; set; } // public string Zip { get; set; } //} #endregion #region Dependency Injection static void Main(string[] args) { //Breads var ryeBread = new RyeBread("Rainbow"); var wheatBread = new WheatBread("Franz"); //Meats var ham = new Ham("Fresh"); var turkey = new Turkey("Rotten"); //Condiments var condiments = new List <ICondiment> { new Mayo("Hellmans"), new Mustard("French's"), new Ketchup("Heinz") }; //Sandwiches var sandwiches = new List <Sandwich> { new Sandwich(ryeBread, ham, condiments), new Sandwich(wheatBread, ham, condiments), new Sandwich(ryeBread, turkey, condiments) }; var sandwichNumber = 1; foreach (var sandwich in sandwiches) { Console.WriteLine($"Making sandwich {sandwichNumber++}"); sandwich.Assemble(); Console.WriteLine("Completed sandwich"); Console.WriteLine(); } Console.ReadKey(); }
public IBaseDuck[] CreatArray() { Random rnd = new Random(); IBaseDuck[] _baseDucks = new IBaseDuck[6]; for (int i = 0; i < 6; i++) { IBaseDuck duck = null; if (rnd.Next(0, 10) % 2 == 0) { IFly F = ReturnFly(rnd.Next(0, 2)); IQuick Q = ReturnQuick(rnd.Next(0, 2)); IComposition C = ReturnComposition(rnd.Next(0, 3)); duck = new Duck(F, Q, C); } else { Turkey turkey; IKudah K = ReturnKudah(rnd.Next(0, 10) % 2); IFly2 F = ReturnFly2(rnd.Next(0, 10) % 2); IComposition C = ReturnComposition(rnd.Next(0, 3)); turkey = new Turkey(F, K, C); duck = new CreateDuck(turkey); } _baseDucks[i] = duck; } return(_baseDucks); }
public TurkeyAdapterClass(Turkey turkey) { Turkey = turkey; }
protected override void VisitInternal(Turkey turkey) => turkey.AmountOfPepperUsed *= 1.05;
static void Main(string[] args) { string ing, kitchen; Console.Write("Enter Country (SA/US): "); kitchen = Console.ReadLine(); Console.Write("Do you want to create a Taco or Burrito? "); ing = Console.ReadLine(); Console.WriteLine(); Console.WriteLine(); if (kitchen == "SA" || kitchen == "sa") { if (ing == "Taco" || ing == "taco") { Taco saTaco = new Taco(new SAIngredientFactory()); Console.WriteLine($"SA Taco: {saTaco.DescribeTaco()}"); } else if (ing == "Burrito" || ing == "burrito") { Burrito saBurrito = new Burrito(new SAIngredientFactory()); Console.WriteLine($"SA Burrito: {saBurrito.DescribeBurrito()}"); } } else if (kitchen == "US" || kitchen == "us") { if (ing == "Taco" || ing == "taco") { Taco usTaco = new Taco(new USIngredientFactory()); Console.WriteLine($"US Taco: {usTaco.DescribeTaco()}"); } else if (ing == "Burrito" || ing == "burrito") { Burrito usBurrito = new Burrito(new USIngredientFactory()); Console.WriteLine($"US Burrito: {usBurrito.DescribeBurrito()}"); } } //----------------------------------- Adding fillings to ingredient for SA Taco kitchen, for burrito just change Taco to burrito in next line Ingredient newIngredientSA = new Taco(new SAIngredientFactory()); string userInputSA = "Yes"; string chosenFillingSA; while (userInputSA == "Yes" || userInputSA == "yes" || userInputSA == "YES") { Console.Write("What filling do you want to add to your ingredient? "); chosenFillingSA = Console.ReadLine(); switch (chosenFillingSA) { case "Chicken": case "chicken": newIngredientSA = new Chicken(newIngredientSA); break; case "Mutton": case "mutton": newIngredientSA = new Mutton(newIngredientSA); break; case "Samp": case "samp": newIngredientSA = new Samp(newIngredientSA); break; case "Chedder Cheese": case "chedder cheese": case "Chedder cheese": newIngredientSA = new CheddarCheese(newIngredientSA); break; case "Sliced Avocados": case "sliced avocados": case "Sliced avocados": newIngredientSA = new SlicedAvocados(newIngredientSA); break; case "Jasmin Rice": case "jasmin rice": case "Jasmin rice": newIngredientSA = new JasminRice(newIngredientSA); break; case "Refried Beans": case "Refried beans": case "refried beans": newIngredientSA = new RefriedBeans(newIngredientSA); break; case "Smooth Cream Cheese": case "smooth cream cheese": case "Smooth Cream cheese": newIngredientSA = new SmoothCreamCheese(newIngredientSA); break; case "Relish": case "relish": newIngredientSA = new Relish(newIngredientSA); break; case "Jalapeno Chilies": case "jalapeno chilies": case "Jalapeno chilies": newIngredientSA = new JalapenoChilies(newIngredientSA); break; }// end switch Console.Write("Do you want to add another filling to your ingredient? "); userInputSA = Console.ReadLine(); } // end while loop Console.WriteLine(); Console.WriteLine(newIngredientSA.GetDiscription() + " \tFinal Price: " + newIngredientSA.Cost().ToString("C")); Console.WriteLine(); //----------------------------------- Adding fillings to ingredient for US Taco kitchen, for burrito just change Taco to Burrito in next line Ingredient newIngredientUS = new Taco(new USIngredientFactory()); string userInputUS = "Yes"; string chosenFillingUS; while (userInputUS == "Yes" || userInputUS == "yes" || userInputUS == "YES") { Console.Write("What filling do you want to add to your ingredient? "); chosenFillingUS = Console.ReadLine(); switch (chosenFillingUS) { case "Turkey": case "turkey": newIngredientUS = new Turkey(newIngredientUS); break; case "Beef": case "beef": newIngredientUS = new Beef(newIngredientUS); break; case "Chickpeas": case "chickpeas": newIngredientUS = new Chickpeas(newIngredientUS); break; case "Pepper Jack Cheese": case "pepper jack cheese": case "Pepper jack cheese": newIngredientUS = new PepperJackCheese(newIngredientUS); break; case "Guacamole": case "guacomole": newIngredientUS = new Guacamole(newIngredientUS); break; case "Basmati Rice": case "basmati rice": case "Basmati rice": newIngredientUS = new BasmatiRice(newIngredientUS); break; case "Black Beans": case "black beans": case "Black beans": newIngredientUS = new BlackBeans(newIngredientUS); break; case "Chunky Cream Cheese": case "chunky cream cheese": case "Chunky Cream cheese": newIngredientUS = new ChunkyCreamCheese(newIngredientUS); break; case "Salsa": case "salsa": newIngredientUS = new Salsa(newIngredientUS); break; case "Habanero Chilies": case "habanero chilies": case "Habanero chilies": newIngredientUS = new HabaneroChilies(newIngredientUS); break; }// end switch Console.Write("Do you want to add another filling to your ingredient? "); userInputUS = Console.ReadLine(); } // end while loop Console.WriteLine(); Console.WriteLine(newIngredientUS.GetDiscription() + " \tFinal Price: " + newIngredientUS.Cost().ToString("C")); Console.WriteLine(); Console.ReadLine(); }
public TurkeyAdapter(Turkey turkey) { _turkey = turkey; }
// Update is called once per frame void Update() { p = gameObject.transform.position; // destroy cannon balls that out of bound if (p.x > dim.x || p.x < -dim.x || p.y < -dim.y || v.magnitude < eps) { Destroy(gameObject); } // Wall collision if (p.x < -dim.x + 0.5f + radius) { v.x -= (1 + restitution) * v.x; gameObject.transform.Translate(v * Time.deltaTime, Space.World); p = gameObject.transform.position; } // Mountain collision // left and right mountain cliff float d1d2; for (int i = 0; i < 3; i++) { d1d2 = Vector2.Distance(p, vertices[i]) + Vector2.Distance(p, vertices[i + 1]); if (d1d2 <= dist[i] + eps && d1d2 >= dist[i] - eps) { v -= (1 + restitution) * Vector2.Dot(v, normals[i]) * normals[i]; gameObject.transform.Translate(v * Time.deltaTime, Space.World); p = gameObject.transform.position; } } // apply gravity v.y += gravity * Time.deltaTime; // apply wind if (p.y > 0.01f) { v.x += wind.windForce / mass * Time.deltaTime; } gameObject.transform.Translate(v * Time.deltaTime, Space.World); p = gameObject.transform.position; // check collision with turkeys for (int i = 0; i < turkeys.Length; i++) { GameObject obj = turkeys[i]; Turkey turkey = obj.GetComponent <Turkey>(); Vector2 turkeyPosi; for (int j = 0; j < 8; j++) { turkeyPosi = new Vector2(turkey.points[j].position.x, turkey.points[j].position.y); if (Vector2.Distance(p, turkeyPosi) <= radius) { turkey.CollideWillBall(v); Destroy(gameObject); break; } } turkeyPosi = new Vector2(turkey.points[18].position.x, turkey.points[18].position.y); if (Vector2.Distance(p, turkeyPosi) <= radius) { turkey.CollideWillBall(v); Destroy(gameObject); break; } } }
void testTurkey(Turkey turkey) { turkey.Gobble(); turkey.Fly(); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Turkey obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Turkey obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; }
public TurkeyPretendingDuck(Turkey turkey) { this.turkey = turkey; }
public void populate_should_not_change_property_values_not_found_in_the_dictionary() { var item = new Turkey(); item.Name = "Smith"; var dict = new Dictionary<string, object> { { "Age", 9 } }; DictionaryConverter.Populate(dict, item, out _problems); item.Name.ShouldEqual("Smith"); item.Age.ShouldEqual(9); }
protected override void VisitInternal(Turkey turkey) => turkey.AmountOfSaltUsed *= 0.85;
public TurkeyAdapter(Turkey pTurkey) { this.mTurkey = pTurkey; }
protected abstract void VisitInternal(Turkey turkey);
public void populate_should_set_all_property_values_present_in_dictionary() { var item = new Turkey(); var dict = new Dictionary<string, object>{{"Name","Boris"}, {"Age","2"}}; DictionaryConverter.Populate(dict, item, out _problems); item.Name.ShouldEqual("Boris"); item.Age.ShouldEqual(2); }
static void Main(string[] args) { // Configure Observer pattern ConcreteKitchen sKitchen = new ConcreteKitchen(); ConcreteKitchen sIngredient = new ConcreteKitchen(); // Sets the predefined observers available sKitchen.Attach(new ConcreteObserver(sKitchen, "Kitchen")); sIngredient.Attach(new ConcreteObserver(sIngredient, "Ingredient")); string ing, kitchen; Console.Write("Enter Country (SA/US): "); kitchen = Console.ReadLine(); switch (kitchen) { // Changes the Kitchen observer to be kitchen location case "US": sKitchen.SubjectState = "US Kitchen"; break; case "us": sKitchen.SubjectState = "US Kitchen"; break; case "SA": sKitchen.SubjectState = "SA Kitchen"; break; case "sa": sKitchen.SubjectState = "SA Kitchen"; break; } //Goes through Subject class to ConcreteObserver class to output in the console window sKitchen.Notify(); //Setting the Ingredient Console.Write("Choose Ingredient Taco/Burrito: "); ing = Console.ReadLine(); switch (ing) { // Changes the Ingredient observer to be an ingredient type case "Taco": sIngredient.SubjectState = "Taco"; break; case "taco": sIngredient.SubjectState = "Taco"; break; case "Burrito": sIngredient.SubjectState = "Burrito"; break; case "burrito": sIngredient.SubjectState = "Burrito"; break; } //Goes through Subject class to ConcreteObserver class to output in the console window sIngredient.Notify(); Console.WriteLine(); Console.WriteLine(); if (kitchen == "SA" || kitchen == "sa" || kitchen == "Sa") { if (ing == "Taco" || ing == "taco" || ing == "TACO") { Taco saTaco = new Taco(new SAIngredientFactory()); Console.WriteLine($"SA Taco: {saTaco.DescribeTaco()}"); // ---------------------------- observer testing Ingredient newIngredientSA = new Taco(new SAIngredientFactory()); string userInputSA = "Yes"; string chosenFillingSA; while (userInputSA == "Yes" || userInputSA == "yes" || userInputSA == "YES") { Console.Write("What filling do you want to add to your ingredient? "); chosenFillingSA = Console.ReadLine(); switch (chosenFillingSA) { case "Chicken": case "chicken": newIngredientSA = new Chicken(newIngredientSA); break; case "Mutton": case "mutton": newIngredientSA = new Mutton(newIngredientSA); break; case "Samp": case "samp": newIngredientSA = new Samp(newIngredientSA); break; case "Cheddar Cheese": case "cheddar cheese": case "Cheddar cheese": newIngredientSA = new CheddarCheese(newIngredientSA); break; case "Sliced Avocados": case "sliced avocados": case "Sliced avocados": newIngredientSA = new SlicedAvocados(newIngredientSA); break; case "Jasmin Rice": case "jasmin rice": case "Jasmin rice": newIngredientSA = new JasminRice(newIngredientSA); break; case "Refried Beans": case "Refried beans": case "refried beans": newIngredientSA = new RefriedBeans(newIngredientSA); break; case "Smooth Cream Cheese": case "smooth cream cheese": case "Smooth Cream cheese": newIngredientSA = new SmoothCreamCheese(newIngredientSA); break; case "Relish": case "relish": newIngredientSA = new Relish(newIngredientSA); break; case "Jalapeno Chilies": case "jalapeno chilies": case "Jalapeno chilies": newIngredientSA = new JalapenoChilies(newIngredientSA); break; }// end switch Console.Write("Do you want to add another filling to your ingredient? "); userInputSA = Console.ReadLine(); } // end while loop Console.WriteLine(); Console.WriteLine(newIngredientSA.GetDiscription() + " \tFinal Price: " + newIngredientSA.Cost().ToString("C")); Console.WriteLine(); // ---------------------------- end observer testing } else if (ing == "Burrito" || ing == "burrito" || ing == "BURRITO") { Burrito saBurrito = new Burrito(new SAIngredientFactory()); Console.WriteLine($"SA Burrito: {saBurrito.DescribeBurrito()}"); // ---------------------------- observer testing Ingredient newIngredientSA = new Burrito(new SAIngredientFactory()); string userInputSA = "Yes"; string chosenFillingSA; while (userInputSA == "Yes" || userInputSA == "yes" || userInputSA == "YES") { Console.Write("What filling do you want to add to your ingredient? "); chosenFillingSA = Console.ReadLine(); switch (chosenFillingSA) { case "Chicken": case "chicken": newIngredientSA = new Chicken(newIngredientSA); break; case "Mutton": case "mutton": newIngredientSA = new Mutton(newIngredientSA); break; case "Samp": case "samp": newIngredientSA = new Samp(newIngredientSA); break; case "Cheddar Cheese": case "cheddar cheese": case "Cheddar cheese": newIngredientSA = new CheddarCheese(newIngredientSA); break; case "Sliced Avocados": case "sliced avocados": case "Sliced avocados": newIngredientSA = new SlicedAvocados(newIngredientSA); break; case "Jasmin Rice": case "jasmin rice": case "Jasmin rice": newIngredientSA = new JasminRice(newIngredientSA); break; case "Refried Beans": case "Refried beans": case "refried beans": newIngredientSA = new RefriedBeans(newIngredientSA); break; case "Smooth Cream Cheese": case "smooth cream cheese": case "Smooth Cream cheese": newIngredientSA = new SmoothCreamCheese(newIngredientSA); break; case "Relish": case "relish": newIngredientSA = new Relish(newIngredientSA); break; case "Jalapeno Chilies": case "jalapeno chilies": case "Jalapeno chilies": newIngredientSA = new JalapenoChilies(newIngredientSA); break; }// end switch Console.Write("Do you want to add another filling to your ingredient? "); userInputSA = Console.ReadLine(); } // end while loop Console.WriteLine(); Console.WriteLine(newIngredientSA.GetDiscription() + " \tFinal Price: " + newIngredientSA.Cost().ToString("C")); Console.WriteLine(); // ---------------------------- end observer testing } } else if (kitchen == "US" || kitchen == "us" || kitchen == "Us") { if (ing == "Taco" || ing == "taco" || ing == "TACO") { Taco usTaco = new Taco(new USIngredientFactory()); Console.WriteLine($"US Taco: {usTaco.DescribeTaco()}"); // ---------------------- observer testing start Ingredient newIngredientUS = new Taco(new USIngredientFactory()); string userInputUS = "Yes"; string chosenFillingUS; while (userInputUS == "Yes" || userInputUS == "yes" || userInputUS == "YES") { Console.Write("What filling do you want to add to your ingredient? "); chosenFillingUS = Console.ReadLine(); switch (chosenFillingUS) { case "Turkey": case "turkey": newIngredientUS = new Turkey(newIngredientUS); break; case "Beef": case "beef": newIngredientUS = new Beef(newIngredientUS); break; case "Chickpeas": case "chickpeas": newIngredientUS = new Chickpeas(newIngredientUS); break; case "Pepper Jack Cheese": case "pepper jack cheese": case "Pepper jack cheese": newIngredientUS = new PepperJackCheese(newIngredientUS); break; case "Guacamole": case "guacomole": newIngredientUS = new Guacamole(newIngredientUS); break; case "Basmati Rice": case "basmati rice": case "Basmati rice": newIngredientUS = new BasmatiRice(newIngredientUS); break; case "Black Beans": case "black beans": case "Black beans": newIngredientUS = new BlackBeans(newIngredientUS); break; case "Chunky Cream Cheese": case "chunky cream cheese": case "Chunky Cream cheese": newIngredientUS = new ChunkyCreamCheese(newIngredientUS); break; case "Salsa": case "salsa": newIngredientUS = new Salsa(newIngredientUS); break; case "Habanero Chilies": case "habanero chilies": case "Habanero chilies": newIngredientUS = new HabaneroChilies(newIngredientUS); break; }// end switch Console.Write("Do you want to add another filling to your ingredient? "); userInputUS = Console.ReadLine(); } // end while loop Console.WriteLine(); Console.WriteLine(newIngredientUS.GetDiscription() + " \tFinal Price: " + newIngredientUS.Cost().ToString("C")); Console.WriteLine(); // ---------------------- observer testing end } else if (ing == "Burrito" || ing == "burrito" || ing == "BURRITO") { Burrito usBurrito = new Burrito(new USIngredientFactory()); Console.WriteLine($"US Burrito: {usBurrito.DescribeBurrito()}"); // ---------------------- observer testing start Ingredient newIngredientUS = new Burrito(new USIngredientFactory()); string userInputUS = "Yes"; string chosenFillingUS; while (userInputUS == "Yes" || userInputUS == "yes" || userInputUS == "YES") { Console.Write("What filling do you want to add to your ingredient? "); chosenFillingUS = Console.ReadLine(); switch (chosenFillingUS) { case "Turkey": case "turkey": newIngredientUS = new Turkey(newIngredientUS); break; case "Beef": case "beef": newIngredientUS = new Beef(newIngredientUS); break; case "Chickpeas": case "chickpeas": newIngredientUS = new Chickpeas(newIngredientUS); break; case "Pepper Jack Cheese": case "pepper jack cheese": case "Pepper jack cheese": newIngredientUS = new PepperJackCheese(newIngredientUS); break; case "Guacamole": case "guacomole": newIngredientUS = new Guacamole(newIngredientUS); break; case "Basmati Rice": case "basmati rice": case "Basmati rice": newIngredientUS = new BasmatiRice(newIngredientUS); break; case "Black Beans": case "black beans": case "Black beans": newIngredientUS = new BlackBeans(newIngredientUS); break; case "Chunky Cream Cheese": case "chunky cream cheese": case "Chunky Cream cheese": newIngredientUS = new ChunkyCreamCheese(newIngredientUS); break; case "Salsa": case "salsa": newIngredientUS = new Salsa(newIngredientUS); break; case "Habanero Chilies": case "habanero chilies": case "Habanero chilies": newIngredientUS = new HabaneroChilies(newIngredientUS); break; }// end switch Console.Write("Do you want to add another filling to your ingredient? "); userInputUS = Console.ReadLine(); } // end while loop Console.WriteLine(); Console.WriteLine(newIngredientUS.GetDiscription() + " \tFinal Price: " + newIngredientUS.Cost().ToString("C")); Console.WriteLine(); // ---------------------- observer testing end } } Console.ReadLine(); }
public void populate_should_set_all_property_values_present_in_dictionary_regardless_of_key_casing() { var item = new Turkey(); var dict = new Dictionary<string, object> { { "nAme", "Smith" }, { "AGE", 9 } }; DictionaryConverter.Populate(dict, item, out _problems); item.Name.ShouldEqual("Smith"); item.Age.ShouldEqual(9); }
public AdapterTurkey(Turkey turkey) { _turkey = turkey; }
public void populate_extra_values_in_dictionary_are_ignored() { var item = new Turkey(); var dict = new Dictionary<string, object> { { "xyzzy", "foo" } }; DictionaryConverter.Populate(dict, item, out _problems); item.Name.ShouldBeNull(); item.Age.ShouldEqual(0); _problems.Count().ShouldEqual(0); }
public TurkeyAdapter(Turkey t) { turkey = t; }
public void populate_should_ignore_a_null_values_dictionary() { var item = new Turkey(); DictionaryConverter.Populate(null, item, out _problems); item.Name.ShouldBeNull(); _problems.Count().ShouldEqual(0); }