public ICar viewCar(CarType carType) { ICar car; switch (carType) { case CarType.HONDA: car = new Honda(); car.view(); return(car); case CarType.KIA: car = new KiA(); car.view(); return(car); case CarType.TOYOTA: car = new Toyota(); car.view(); return(car); default: car = new Honda(); car.view(); return(car); } }
static void FuncEnum(Toyota model1, Toyota model2) { if (model1 == Toyota.Prius) { Console.WriteLine(Toyota.Prius.ToString()); } }
static void Main(string[] args) { int a = 0; int b = 0; Car car1 = new Mazda(1500, 4000); Car car2 = new Toyota(2000, 3000); try { a = car1.summ(); b = car2.summ(); if ((a | b) > 5000) { throw new Exception(); } } catch (Exception e) { Console.WriteLine("Too expensive"); } finally { Console.WriteLine(a); Console.WriteLine(b); } Console.Read(); }
static void Main() { //when below line is executed,constructor is fired & the initialization of variable inside constructor takes place var myVar = new Toyota(); Console.WriteLine(myVar.DisplayName); }
public IAuto CreateEconomyCar() { var auto = new Toyota(); auto.AddEconomyPackage(); return(auto); }
public IAuto CreateAuto() { IAuto auto = new Toyota(); auto.SetName("Tojota"); return(auto); }
public static void Main() { Car c = new Toyota(); Toyota t = new Toyota(); Console.WriteLine(c.color); Console.WriteLine(t.color); }
public IAuto CreateLuxuryCar() { var auto = new Toyota(); auto.AddLuxuryPackage(); return(auto); }
public IAuto CreateSportsCar() { var auto = new Toyota(); auto.AddSportsPackage(); return(auto); }
static void main() { int speed = GetSpeed(); var my = new Toyota(); var myOther = new Honda(); my.Drive(speed); myOther.Drive(speed); }
public void RegistrationWithParamsTestMethod() { var container = new Container(); container.Register(typeof(Toyota)); object[] parameters = { "Corolla", 2008 }; var expected = new Toyota(); Assert.AreEqual(expected.GetType(), container.Resolve(typeof(Toyota), parameters).GetType()); }
private static void Main(string[] args) { Toyota t = new Toyota() { EngineType = new EngineType() }; Console.WriteLine(t.DisplayName); Console.ReadLine(); }
public static void LiskovPrinciple() { Car myLamborghini = new Car(); myLamborghini.DriveTo("Los Santos"); Vehicle myVehicle = new Car(); Car myToyota = new Toyota(); myToyota.DriveTo("Pitesti"); }
public void RegistrationWithLabelsTestMethod() { var container = new Container(); container.Register(typeof(ICar), typeof(BMW), "BMW X5"); container.Register(typeof(ICar), typeof(Toyota), "Toyota Celica"); var bmwExpected = new BMW(); var toyotaExpected = new Toyota(); var bmwActual = container.Resolve(typeof(ICar), "BMW X5"); var toyotaActual = container.Resolve(typeof(ICar), "Toyota Celica"); Assert.AreEqual(2, container.Count); Assert.AreEqual(bmwExpected.GetType(), bmwActual.GetType()); Assert.AreEqual(toyotaExpected.GetType(), toyotaActual.GetType()); }
public async Task <Guid> CreateToyota(string name) { var toyota = new Toyota { Name = name }; using (var session = _documentStore.LightweightSession()) { session.Store(toyota); session.SaveChanges(); } return(toyota.Id); }
static void Main(string[] args) { var toyota = new Toyota(); Car nissan = new Nissan(); Console.WriteLine("Введите количество шин для Марки Тойота"); toyota.wheels = Int32.Parse(Console.ReadLine()); Console.WriteLine("Введите количество шин для Ниссана"); nissan.wheels = int.Parse(Console.ReadLine()); var SumWheels = toyota + nissan; Console.WriteLine("Перегруженный оператор суммирует колёса марок \n Итого:" + "" + SumWheels.wheels + "шин"); Console.ReadLine(); }
public static void Start() { BaseCar a = new BaseCar(); Toyota b = new Toyota(); Motobyke c = new Motobyke(); // The following is valid because BaseCar is the specified base class. Test <BaseCar> t1 = new Test <BaseCar>(a); t1.SayHello(); // The following is valid because Toyota inherits BaseCar. Test <Toyota> t2 = new Test <Toyota>(b); t2.SayHello(); // The following is invalid because Motobyke does not inherit BaseCar. // Test<C> t3 = new Test<C>(c); // Error! // t3.SayHello(); // Error! }
public void Publish(Toyota.Tsusho.CRM.API.MessageContracts.ContactPublishRequestMessage request) { throw new NotImplementedException(); }
static void Main(string[] args) { Console.WriteLine("Regular Visitor pattern"); VisitorDomain.IFruitVisitor visitor = new VisitorDomain.FruitVisitor(); VisitorDomain.Fruit apple = new VisitorDomain.Apple("Golden delicious"); VisitorDomain.Fruit grape = new VisitorDomain.Grape("Merlot"); apple.Accept(visitor); grape.Accept(visitor); Console.WriteLine("======================="); Console.WriteLine("Acyclic Visitor pattern"); DegenerateVegetableVisitor acyclicVisitor = new CarretVisitor(); Vegetable carret = new Carret("Red"); carret.Accept(acyclicVisitor); acyclicVisitor = new CucumberVisitor(); Vegetable cucumber = new Cucumber("Green"); cucumber.Accept(acyclicVisitor); Console.WriteLine("======================="); Console.WriteLine("Generic Acyclic Visitor pattern"); CarVisitor carVisitor = new CarVisitor <Toyota>(); Toyota toyota = new Toyota("Corrolla"); toyota.Accept(carVisitor); carVisitor = new CarVisitor <Bmw>() as CarVisitor; Bmw bmw = new Bmw("4"); bmw.Accept(carVisitor); carVisitor = new CarVisitor <Mercedes>() as CarVisitor; Mercedes mercedes = new Mercedes("default"); mercedes.Accept(carVisitor); Console.WriteLine("======================="); Console.WriteLine("Full Visitor pattern"); List <FullDomain.Fruit> fruits = new List <FullDomain.Fruit>() { new FullDomain.Grape() { NumberOfGrapes = 3 }, new FullDomain.Banana() { NumberOfFingers = 4 }, new FullDomain.Apple(), new FullDomain.Grape() { NumberOfGrapes = 6 }, new FullDomain.Banana() { NumberOfFingers = 3 }, new FullDomain.Apple(), new FullDomain.Apple(), new FullDomain.Grape() { NumberOfGrapes = 7 }, new FullDomain.Grape() { NumberOfGrapes = 4 }, new FullDomain.Banana() { NumberOfFingers = 3 } }; List <FullDomain.Apple> allApples = FullDomain.FruitExtensions.Pick <FullDomain.Apple>(fruits).ToList(); // Because of namespace clashes I call extension method like this Console.WriteLine($"Number of apples visited {allApples.Count}"); List <FullDomain.Grape> allGrapes = FullDomain.FruitExtensions.Pick <FullDomain.Grape>(fruits).ToList(); // Because of namespace clashes I call extension method like this Console.WriteLine($"Number of grape objects visited {allGrapes.Count}, number of grapes {allGrapes.Sum(s => s.NumberOfGrapes)}"); List <FullDomain.Banana> allBananas = FullDomain.FruitExtensions.Pick <FullDomain.Banana>(fruits).ToList(); // Because of namespace clashes I call extension method like this Console.WriteLine($"Number of bananas visited {allBananas.Count}, number of fingers {allBananas.Sum(s => s.NumberOfFingers)}"); FullDomain.FruitWeightCalculatorVisitor weightCalculator = new FullDomain.FruitWeightCalculatorVisitor(); fruits.ForEach(fruit => fruit.Accept(weightCalculator)); Console.WriteLine($"Weight of fruits {weightCalculator.WeightInGrams}"); Console.Write("Press any key to continue. . ."); Console.ReadKey(); }
public Form1() { InitializeComponent(); using (var context = new Model1Container()) { var d1 = new Dealer { Name = "All Cities Toyota" }; var d2 = new Dealer { Name = "Southtown Toyota" }; var d3 = new Dealer { Name = "Luxury Auto World" }; var c1 = new Toyota { Model = "Camry", Color = "Green", Year = 2014, Dealer = d1 }; var c2 = new BMW { Model = "310i", Color = "Blue", CollisionAvoidance = true, Year = 2014, Dealer = d3 }; var c3 = new Toyota { Model = "Tundra", Color = "Blue", Year = 2014, Dealer = d2 }; context.Dealers.Add(d1); context.Dealers.Add(d2); context.Dealers.Add(d3); context.SaveChanges(); } using (var context = new Model1Container()) { Console.WriteLine("Dealers and Their Cars"); Console.WriteLine("======================"); foreach (var dealer in context.Dealers) { Console.WriteLine("\nDealer: {0}", dealer.Name); foreach (var car in dealer.Cars) { string make = string.Empty; if (car is Toyota) { make = "Toyota"; } else if (car is BMW) { make = "BMW"; } Console.WriteLine("\t{0} {1} {2} {3}", car.Year, car.Color, make, car.Model); } } } }
public static void Main() { // TESTING THE METHOD var toyota = new Toyota(); var demhamVal = new DenhamVale(); CalulateSdt(demhamVal.DistanceInMiles, toyota.SpeedMph); Console.WriteLine("Welcome To My Program"); Console.WriteLine("Please See List and pick a car for your journey: "); Toyota t = new Toyota(); t.Intro(); t.Speed(); t.Engine(); Fiat f = new Fiat(); f.Intro(); f.Speed(); f.Engine(); Honda h = new Honda(); h.Intro(); h.Speed(); h.Engine(); string input; input = Console.ReadLine(); if (string.Equals(A, input, StringComparison.CurrentCultureIgnoreCase)) { string input2; Console.WriteLine("You have chosen to drive the toyota." + Environment.NewLine + "Please pick a route: "); List <Route> Routes = new List <Route>(); Routes.Add(new CandyLane()); Routes.Add(new BostonAvenue()); Routes.Add(new DenhamVale()); foreach (Route Route in Routes) { Route.Intro(); Route.Distance(); Route.SurfaceType(); } input2 = Console.ReadLine(); if (string.Equals(D, input2, StringComparison.CurrentCultureIgnoreCase)) { string input3; Console.WriteLine("You have chosen: Candy Lane" + Environment.NewLine + "Is it raining or sunny?"); input3 = Console.ReadLine(); if (string.Equals(R, input3, StringComparison.CurrentCultureIgnoreCase)) { Console.WriteLine("You have chosen Raining. + 10 minutes..."); } } else if (string.Equals(E, input2, StringComparison.CurrentCultureIgnoreCase)) { Console.WriteLine("You have chosen: Boston Avenue" + Environment.NewLine + "Is it raining or sunny?"); } else if (string.Equals(F, input2, StringComparison.CurrentCultureIgnoreCase)) { Console.WriteLine("You have chosen: Denham Vale" + Environment.NewLine + "Is it raining or sunny?"); } else { Console.WriteLine("This Route Doesnt Exsist"); } } else if (string.Equals(B, input, StringComparison.CurrentCultureIgnoreCase)) { string input2; Console.WriteLine("You have chosen to drive the Fiat." + Environment.NewLine + "Please pick a route: "); List <Route> Routes = new List <Route>(); Routes.Add(new CandyLane()); Routes.Add(new BostonAvenue()); Routes.Add(new DenhamVale()); foreach (Route Route in Routes) { Route.Intro(); Route.Distance(); Route.SurfaceType(); } input2 = Console.ReadLine(); if (string.Equals(D, input2, StringComparison.CurrentCultureIgnoreCase)) { Console.WriteLine("You have chosen: Candy Lane" + Environment.NewLine + "Is it raining or sunny?"); } } else if (string.Equals(C, input, StringComparison.CurrentCultureIgnoreCase)) { string input2; Console.WriteLine("You have chosen to drive the Honda." + Environment.NewLine + "Please pick a route: "); List <Route> Routes = new List <Route>(); Routes.Add(new CandyLane()); Routes.Add(new BostonAvenue()); Routes.Add(new DenhamVale()); foreach (Route Route in Routes) { Route.Intro(); Route.Distance(); Route.SurfaceType(); } input2 = Console.ReadLine(); if (string.Equals(D, input2, StringComparison.CurrentCultureIgnoreCase)) { Console.WriteLine("You have chosen: Candy Lane" + Environment.NewLine + "Is it raining or sunny?"); } } }
public void Notify(Toyota.Tsusho.CRM.API.MessageContracts.OrderNotifyRequestMessage request) { using (OrganizationServiceProxy proxy = CRMHelper.Connect()) { ServiceContext context = new ServiceContext(proxy); foreach (OrderItemDataContract item in request.Items) { bool add = false; Entity entity = null; Invoice record = (from a in context.InvoiceSet where a.new_saporderno == item.Invoice.new_saporderno select a).FirstOrDefault(); if (record == null) { add = true; record = new Invoice(); } //CustomerId Lookup Contact contact = (from c in context.ContactSet where c.new_customeraccountnumber == item.Invoice.CustomerId.Name select c).FirstOrDefault(); if (contact == null) throw new Exception(String.Format("No Contact could be retrieved for {0}", item.Invoice.CustomerId.Name)); //SalesOrder SalesOrder order = null; if (item.Invoice.SalesOrderId != null) { order = (from o in context.SalesOrderSet where o.new_DBMOrderNumber == item.Invoice.SalesOrderId.Name select o).FirstOrDefault(); } //SalesOffice Territory salesOffice = null; if (item.Invoice.new_salesoffice != null) { entity = (from s in context.CreateQuery("territory") where s["new_sapcode"] == item.Invoice.new_salesoffice.Name select s).FirstOrDefault(); if (entity != null) salesOffice = entity.ToEntity<Territory>(); } //Plant entity = (from p in context.CreateQuery("territory") where p["new_sapcode"] == item.Invoice.new_plant.Name select p).FirstOrDefault(); Territory plant = null; if(entity != null) plant = entity.ToEntity<Territory>(); //new_invoicetype new_invoicetype invoiceType = null; if(item.Invoice.new_invoicetype != null) { entity = (from it in context.CreateQuery("new_invoicetype") where it["new_typeidinvoice"] == item.Invoice.new_invoicetype.Name select it).FirstOrDefault(); if(entity != null) invoiceType = entity.ToEntity<new_invoicetype>(); } //Populate Order Fields record.new_saporderno = item.Invoice.new_saporderno; record.new_client = item.Invoice.new_client; if (contact != null) record.CustomerId = contact.ToEntityReference(); if (order != null) record.SalesOrderId = order.ToEntityReference(); record.new_precedingdocument = item.Invoice.new_precedingdocument; if (salesOffice != null) record.new_salesoffice = salesOffice.ToEntityReference(); if(plant != null) record.new_plant = plant.ToEntityReference(); record.new_customeradviser = item.Invoice.new_customeradviser; record.new_billingdate = item.Invoice.new_billingdate; record.new_licenseplatenumber = item.Invoice.new_licenseplatenumber; record.new_country = item.Invoice.new_country; record.new_counterreading = item.Invoice.new_counterreading; record.new_counterunit = item.Invoice.new_counterunit; record.new_orderstatus = item.Invoice.new_orderstatus; record.new_netvalue = item.Invoice.new_netvalue; record.new_vehicleguid = item.Invoice.new_vehicleguid; if (invoiceType != null) record.new_invoicetype = invoiceType.ToEntityReference(); if (add) context.AddObject(record); else context.UpdateObject(record); //Invoice Detail //We will nowdelete all line item s and readd them //if we do not do this we will get duplicate records. if (record.invoice_details != null) { foreach (InvoiceDetail detail in record.invoice_details) context.DeleteObject(detail); } foreach (InvoiceDetail lineItem in item.InvoiceDetails) { InvoiceDetail detail = new InvoiceDetail(); //new_material new_modelsalescode material = null; if(detail.new_material != null) { material = (from m in context.new_modelsalescodeSet where m.new_name == lineItem.new_material.Name select m).FirstOrDefault(); } //Plant Territory detailPlant = null; if (lineItem.new_plant != null) { entity = (from p in context.CreateQuery("territory") where p["new_sapcode"] == lineItem.new_plant.Name select p).FirstOrDefault(); if (entity != null) detailPlant = entity.ToEntity<Territory>(); } //Populate Invoice Detail detail.LineItemNumber = lineItem.LineItemNumber; detail.new_pricingreferencematerial = lineItem.new_pricingreferencematerial; detail.new_lvhierno = lineItem.new_lvhierno; if (material != null) detail.new_material = material.ToEntityReference(); detail.new_materialgroup = lineItem.new_materialgroup; detail.ProductDescription = lineItem.ProductDescription; detail.IsPriceOverridden = lineItem.IsPriceOverridden; detail.IsProductOverridden = lineItem.IsProductOverridden; detail.new_description1 = lineItem.new_description1; detail.new_itemcategory = lineItem.new_itemcategory; detail.new_deleteitem = lineItem.new_deleteitem; detail.Quantity = lineItem.Quantity; detail.new_targetqtyuom = lineItem.new_targetqtyuom; detail.new_baseunit = lineItem.new_baseunit; detail.new_targetqtyuom = lineItem.new_targetqtyuom; detail.new_division = lineItem.new_division; detail.PricePerUnit = lineItem.PricePerUnit; detail.new_salesunit = lineItem.new_salesunit; if (detailPlant != null) detail.new_plant = detailPlant.ToEntityReference(); detail.new_storagelocation = lineItem.new_storagelocation; context.AddRelatedObject(record, new Relationship("invoice_details"), detail); } } context.SaveChanges(); } }
public void SetupTest() { t = new Toyota().Login(); }