private void Run() { Product someProduct = factory.CreateProduct("ProductOne"); Product otherProduct = factory.CreateProduct("ProductTwo"); Console.WriteLine("Product: '{0}' costs: {1}$", someProduct.GetName(), someProduct.GetPrice()); Console.WriteLine("Product: '{0}' costs: {1}$", otherProduct.GetName(), otherProduct.GetPrice()); }
static void Main(string[] args) { ProductFactory factory1 = new ProductFactory(); factory1.CreateProduct("PD_001"); factory1.CreateProduct("PD_002"); factory1.CreateProduct("PD_003"); }
public void Init() { sm.InfoLoad(); for (int i = 0; i < 3; i++) { if (sm.Saves[i] != null && m_LoadText[i] != null) { m_LoadText[i].text = sm.Saves[i].Time.ToString(); } else if (m_LoadText[i] != null) { m_LoadText[i].text = ""; } } m_TaskNum = 0; //当前任务ID player_position = new Vector3(0, 0, 0); //记录场景移动时下一次移动的坐标,z坐标一般为0 //三个人物 //p1 = new Person(0, "小黑", 1000, 9999, 20, 30, 11, 18, 8, 1, 0, 3, 2, 2, 3, 4, 1, 1, "myimport/zhujue1/女主行走图", 2, 0, 0); //p2 = new Person(1, "小绿", 1000, 9999, 20, 30, 12, 18, 8, 1, 0, 3, 2, 2, 3, 4, 1, 1, "myimport/Npc/038-Mage06", 2, 0, 0); //p3 = new Person(2, "小蓝", 1000, 9999, 20, 30, 51, 18, 8, 1, 0, 3, 2, 2, 3, 4, 1, 1, "myimport/Npc/001-Fighter01", 2, 0, 0); p1 = new Person(0, "克萝莉亚", 590, 570, 50, 48, 73, 10, 10, 1, 0, 53, 14, 15, 7, 3, 2, 49, "myimport/zhujue1/女主行走图", 2, 0, 0); p2 = new Person(1, "西露达", 422, 606, 35, 71, 46, 8, 12, 1, 0, 47, 20, 11, 5, 2, 3, 56, "myimport/Npc/038-Mage06", 2, 0, 0); p3 = new Person(2, "帕吉尔", 710, 535, 67, 40, 58, 12, 8, 1, 0, 69, 9, 18, 6, 3, 2, 49, "myimport/Npc/001-Fighter01", 2, 0, 0); //背包,包括装备,物品,金钱 bag = new BackPack(); tk = new TalkText(); tl = new TaskList(); tk = new TalkText(); p1.AddSkill(p1.skillFactory.CreateSkill("无限剑制")); p1.AddSkill(p1.skillFactory.CreateSkill("六脉神剑")); p1.AddSkill(p1.skillFactory.CreateSkill("八荒六合")); p2.AddSkill(p2.skillFactory.CreateSkill("大火球")); p2.AddSkill(p2.skillFactory.CreateSkill("岩浆爆破")); p2.AddSkill(p2.skillFactory.CreateSkill("烈焰风暴")); p3.AddSkill(p3.skillFactory.CreateSkill("瞬劈")); p3.AddSkill(p3.skillFactory.CreateSkill("生死不觉")); p3.AddSkill(p3.skillFactory.CreateSkill("临危不惧")); bag.Money = 500; ProductFactory pf = new ProductFactory(); bag.SetGoods(pf.CreateProduct("血气丸", 3)); bag.SetGoods(pf.CreateProduct("凝神露", 3)); EquipmentFactory ef = new EquipmentFactory(); bag.SetGoods(ef.CreateEquipment("铁盔")); bag.SetGoods(ef.CreateEquipment("大法师之帽")); }
public string AddProduct(string type, double price) { Product product = productFactory.CreateProduct(type, price); products.Add(product); return($"Added {type} to pool"); }
/// <summary> /// Oλες οι configure μέθοδοι αν υπήρχε gui θα χαν ξεχωριστα τη λογικη ui και control /// </summary> /// <param name="productFactory"></param> /// <returns></returns> private static PCScreen ConfigurePCScreen(ProductFactory productFactory) { string answer; Console.WriteLine("Insert screen size in inches\n"); answer = Console.ReadLine(); PCScreen pcScreen = productFactory.CreateProduct("PCScreen") as PCScreen; if (!pcScreen.SetScreenSize(answer)) { WrongInput(); return(productFactory.CreateProduct("PCScreen") as PCScreen); } return(pcScreen); }
private static IEnumerable <Product> GenerateProducts() { var products = new List <Product>(); products.Add(ProductFactory.CreateProduct("Refrigerator", 300m)); products.Add(ProductFactory.CreateProduct("Bottle opener", 1.90m)); products.Add(ProductFactory.CreateProduct("Mixer", 24.5m)); products.Add(ProductFactory.CreateProduct("Gas stove", 290m)); products.Add(ProductFactory.CreateProduct("Electric kettle", 45.95m)); products.Add(ProductFactory.CreateProduct("Microwave oven", 120m)); products.Add(ProductFactory.CreateProduct("Cast iron frying pan", 56.95m)); products.Add(ProductFactory.CreateProduct("Blender", 89m)); products.Add(ProductFactory.CreateProduct("Dishwasher", 255m)); products.Add(ProductFactory.CreateProduct("Teflon coating pan", 29.99m)); products.Add(ProductFactory.CreateProduct("Set of chef's knives", 119m)); products.Add(ProductFactory.CreateProduct("Baking thermometer", 3.75m)); products.Add(ProductFactory.CreateProduct("Wooden spice rack", 19.50m)); products.Add(ProductFactory.CreateProduct("Rolling pin", 4.5m)); products.Add(ProductFactory.CreateProduct("Set of 6 beer glasses", 34.90m)); products.Add(ProductFactory.CreateProduct("Waffle pan", 29.30m)); products.Add(ProductFactory.CreateProduct("Grill oven", 199m)); products.Add(ProductFactory.CreateProduct("Egg timer", 1.99m)); products.Add(ProductFactory.CreateProduct("Cutting board", 8.9m)); products.Add(ProductFactory.CreateProduct("Wine decanter", 34.50m)); products.Add(ProductFactory.CreateProduct("Chopsticks", 0.99m)); products.Add(ProductFactory.CreateProduct("Stainless steel kitchen sink", 89m)); products.Add(ProductFactory.CreateProduct("Coffee mug", 3.95m)); products.Add(ProductFactory.CreateProduct("Tea cup", 2.65m)); products.Add(ProductFactory.CreateProduct("Silver spoon", 99m)); return(products); }
public Member() { Response = System.Web.HttpContext.Current.Response; Request = System.Web.HttpContext.Current.Request; Server = System.Web.HttpContext.Current.Server; Session = System.Web.HttpContext.Current.Session; Application = System.Web.HttpContext.Current.Application; tools = ToolsFactory.CreateTools(); MyMember = MemberFactory.CreateMember(); Mygrade = MemberGradeFactory.CreateMemberGrade(); MyMemLog = MemberLogFactory.CreateMemberLog(); encrypt = EncryptFactory.CreateEncrypt(); MyConsumption = MemberConsumptionFactory.CreateMemberConsumption(); MyFavor = MemberFavoritesFactory.CreateMemberFavorites(); MyProduct = ProductFactory.CreateProduct(); MyPackage = PackageFactory.CreatePackage(); MyReview = ProductReviewFactory.CreateProductReview(); MyFeedback = FeedBackFactory.CreateFeedBack(); MyAddr = MemberAddressFactory.CreateMemberAddress(); MyCart = OrdersGoodsTmpFactory.CreateOrdersGoodsTmp(); MyCoupon = PromotionFavorCouponFactory.CreatePromotionFavorCoupon(); // MyEmail = U_EmailNotifyRequestFactory.CreateU_EmailNotifyRequest(); MyAccountLog = MemberAccountLogFactory.CreateMemberAccountLog(); MyShop = SupplierShopFactory.CreateSupplierShop(); pageurl = new PageURL(int.Parse(Application["Static_IsEnable"].ToString())); }
public static IEnumerable <ProductQuantity> CreateProducts(IEnumerable <string> products) { var productsAndQuantities = new List <ProductQuantity>(); var productFactory = new ProductFactory(); foreach (var product in products) { var existProduct = productsAndQuantities.SingleOrDefault(item => string.Equals(item.Product.ProductName, product, StringComparison.CurrentCultureIgnoreCase)); if (existProduct == null) { productsAndQuantities.Add(new ProductQuantity { Product = productFactory.CreateProduct(product), Quantity = 1 }); } else { existProduct.Quantity += 1; } } return(productsAndQuantities); }
public Orders() { Response = System.Web.HttpContext.Current.Response; Request = System.Web.HttpContext.Current.Request; Server = System.Web.HttpContext.Current.Server; Session = System.Web.HttpContext.Current.Session; Application = System.Web.HttpContext.Current.Application; tools = ToolsFactory.CreateTools(); encrypt = EncryptFactory.CreateEncrypt(); MyOrders = OrdersFactory.CreateOrders(); Mylog = OrdersLogFactory.CreateOrdersLog(); MyDelivery = DeliveryWayFactory.CreateDeliveryWay(); MyPayway = PayWayFactory.CreatePayWay(); MyProduct = ProductFactory.CreateProduct(); Mypackage = PackageFactory.CreatePackage(); Myorderdelivery = OrdersDeliveryFactory.CreateOrdersDelivery(); MyFavorFee = PromotionFavorFeeFactory.CreatePromotionFavorFee(); MyCoupon = PromotionFavorCouponFactory.CreatePromotionFavorCoupon(); MyBack = OrdersBackApplyFactory.CreateOrdersBackApply(); MyPolicy = PromotionFavorPolicyFactory.CreatePromotionFavorPolicy(); MySupplier = SupplierFactory.CreateSupplier(); Mydelierytime = DeliveryTimeFactory.CreateDeliveryTime(); MyMember = MemberFactory.CreateMember(); MyConsumption = MemberConsumptionFactory.CreateMemberConsumption(); pageurl = new PageURL(int.Parse(Application["Static_IsEnable"].ToString())); MyAccountLog = MemberAccountLogFactory.CreateMemberAccountLog(); MyFavor = PromotionFavorFactory.CreatePromotionFavor(); MyCouponRule = PromotionCouponRuleFactory.CreatePromotionFavorCoupon(); MyInvoice = OrdersInvoiceFactory.CreateOrdersInvoice(); }
public void SetUp() { var productOnOffer = ProductFactory.CreateProduct(ProductType.Bread, 1); var conditionForOffer = ProductFactory.CreateProduct(ProductType.Butter, 2); _percentageOffer = new PercentageOffer(productOnOffer, conditionForOffer, 50); }
public string AddProduct(string type, double price) { var product = productFactory.CreateProduct(type, price); this.productsPool.Add(product); return($"Added {type} to pool"); }
public void CreateProduct_WhenNoCurrentCategory_CreatesValidModel() { var name = "new product"; var categoryName = "category"; var category = new Category { Name = categoryName }; var description = "this is a brand new product"; var product = new ProductDto { Name = name, Description = description, Category = categoryName }; var mockContext = new Mock <DALContext>(); mockContext.Setup(x => x.GetCategoryByName(categoryName)).Returns((Category)null); var model = ProductFactory.CreateProduct(product, mockContext.Object); Assert.NotNull(model); Assert.Equal(name, model.Name); Assert.Equal(description, model.Description); Assert.Equal(categoryName, model.Category.Name); }
public void BeginAlgorithm(string error) { int people; float margin; using (AlgorithmDialog dialog = new AlgorithmDialog()) { dialog.OpenDialog(error); if (dialog.Result.Count > 0) { people = (int)dialog.Result["People"]; margin = dialog.Result["Margin"] / 100; // Margin is given in centimeters (so we don't have inconsistensies between system languages } // e.g in Dutch you use a comma to denote a floating point, while in English you would use a period). else { people = 0; margin = 0; } } ComboBox algorithmComboBox = (ComboBox)view.Get(ProductGrid.PropertyEnum.AlgorithmComboBox); AlgorithmModel selectedAlgorithm = (AlgorithmModel)algorithmComboBox.SelectedItem; // Example chair and table ProductModel chair = ProductFactory.CreateProduct("Ahrend", 1, 1, "Stoelen", new CategoryModel(5, "Stoel", 0, "White")); ProductModel table = ProductFactory.CreateProduct("TableCompany", 2, 1, "Tafels", new CategoryModel(8, "Tafel", 2, "White")); StartAlgorithm(selectedAlgorithm, chair, table, people, margin); }
public Cart() { Response = System.Web.HttpContext.Current.Response; Request = System.Web.HttpContext.Current.Request; Server = System.Web.HttpContext.Current.Server; Session = System.Web.HttpContext.Current.Session; Application = System.Web.HttpContext.Current.Application; tools = ToolsFactory.CreateTools(); encrypt = EncryptFactory.CreateEncrypt(); MyOrders = OrdersFactory.CreateOrders(); MyCart = OrdersGoodsTmpFactory.CreateOrdersGoodsTmp(); MyProduct = ProductFactory.CreateProduct(); MyMem = MemberFactory.CreateMember(); Mypackage = PackageFactory.CreatePackage(); MyAddr = MemberAddressFactory.CreateMemberAddress(); MyDelivery = DeliveryWayFactory.CreateDeliveryWay(); MyPayway = PayWayFactory.CreatePayWay(); Mydelierytime = DeliveryTimeFactory.CreateDeliveryTime(); MyInvioce = OrdersInvoiceFactory.CreateOrdersInvoice(); MyFavorFee = PromotionFavorFeeFactory.CreatePromotionFavorFee(); MyCoupon = PromotionFavorCouponFactory.CreatePromotionFavorCoupon(); MyPolicy = PromotionFavorPolicyFactory.CreatePromotionFavorPolicy(); MyGift = PromotionFavorGiftFactory.CreatePromotionFavorGift(); MyCommission = SupplierCommissionCategoryFactory.CreateSupplierCommissionCategory(); MySupplier = SupplierFactory.CreateSupplier(); MyFavor = PromotionFavorFactory.CreatePromotionFavor(); MyLimit = PromotionLimitFactory.CreatePromotionLimit(); MyMemberFavor = MemberFavoritesFactory.CreateMemberFavorites(); pageurl = new PageURL(int.Parse(Application["Static_IsEnable"].ToString())); }
public void ProductFactory_ShouldThrowException() { ProductFactory productFactory = new ProductFactory(); Assert.Throws <InvalidOperationException>( () => productFactory.CreateProduct("NotExisting", 1.2)); }
public string ReceiveProduct(List <string> args) { string type = args[0]; string name = args[1]; string storeName = args[args.Count - 1]; if (!_stores.ContainsKey(storeName)) { return($"Invalid Store: {storeName}. Cannot find it in system!"); } Product product = ProductFactory.CreateProduct(args.Take(5).ToList()); if (product == null) { return($"Product {type} is invalid!"); } bool isReceived = _stores[storeName].ReceiveProduct(product); if (!isReceived) { return($"Product {name} was already delivered to {storeName}!"); } return($"Product {name} was successfully delivered to {storeName}!"); }
public static void Create(int productTypeId, String name, int stock, int price) { Product prk = ProductFactory.CreateProduct(productTypeId, name, stock, price); db.Products.Add(prk); db.SaveChanges(); }
public void InvalidProductQuantityThrowsException() { // Arrange // Act // Assert Assert.Throws <ArgumentException>(() => ProductFactory.CreateProduct(ProductType.Milk, 0)); }
public void ValidProductFactory() { ProductFactory productFactory = new ProductFactory(); var product = productFactory.CreateProduct("Ram", 1.2); Assert.AreEqual("Ram", product.GetType().Name); }
public void ProductFactory_ShouldWorkCorrectly() { ProductFactory productFactory = new ProductFactory(); Product product = productFactory.CreateProduct("Gpu", 1.2); Assert.That(typeof(Product).IsAssignableFrom(product.GetType())); }
public string AddProduct(string type, double price) { Product product = productFactory.CreateProduct(type, price); pool.Add(product); return(string.Format(Messages.successfulAddedProductToPool, type)); }
/// <summary> /// Update a product. /// </summary> public Product UpdateProduct(int id, string name, string description = "") { var product = ProductFactory.CreateProduct(name, description, id); _commands.UpdateProduct(product); return(_queries.GetProduct(product.Id)); }
/// <summary> /// Insert a product. /// </summary> public Product AddProduct(Product product) { var productDao = ProductFactory.CreateProductDao(product); productDao = Insert(productDao); return(ProductFactory.CreateProduct(productDao)); }
public async Task <IActionResult> Create([FromBody] NewUpdateProduct newProduct) { var product = ProductFactory.CreateProduct(newProduct); await _writeRepository.CreateAsync(product); return(Ok(product)); }
private static PersonalComputer ConfigurePersonalComputer(ComponentFactory componentFactory, ProductFactory productFactory) { string answer; PersonalComputer personalComputer; PCTower pcTower = ConfigurePCTower(componentFactory, productFactory); if (!pcTower.IsValidProduct()) { return(productFactory.CreateProduct("PersonalComputer") as PersonalComputer); } PCScreen pcScreen = ConfigurePCScreen(productFactory); if (!pcScreen.IsValidProduct()) { return(productFactory.CreateProduct("PersonalComputer") as PersonalComputer); } Console.WriteLine("Set the size of the Hard Disk\n"); answer = Console.ReadLine(); HardDrive hardDrive = componentFactory.CreateComponent("HardDrive") as HardDrive; if (!hardDrive.SetValue(answer)) { WrongInput(); return(productFactory.CreateProduct("PersonalComputer") as PersonalComputer); } personalComputer = productFactory.CreateProduct("PersonalComputer") as PersonalComputer; if (!personalComputer.SetScreen(pcScreen)) { WrongInput(); return(productFactory.CreateProduct("PersonalComputer") as PersonalComputer); } if (!personalComputer.SetPCTower(pcTower)) { WrongInput(); return(productFactory.CreateProduct("PersonalComputer") as PersonalComputer); } ; if (!personalComputer.SetHardDrive(hardDrive)) { WrongInput(); return(productFactory.CreateProduct("PersonalComputer") as PersonalComputer); } if (!personalComputer.IsValidProduct()) { return(productFactory.CreateProduct("PersonalComputer") as PersonalComputer); } return(personalComputer); }
public static Boolean insertProduct(string productName, int productStock, int productPrice, int productTypeID) { Product product = ProductFactory.CreateProduct(productTypeID, productName, productPrice, productStock); db.Products.Add(product); db.SaveChanges(); return(true); }
public void ProductQuantityHasCorrectValue() { // Arrange // Act var products = ProductFactory.CreateProduct(ProductType.Butter, 2); // Assert Assert.AreEqual(2, products.Quantity); }
public void ShouldHaveCorrectTotal(ProductType productType, int quantity, decimal expectedTotal) { // Arrange // Act var products = ProductFactory.CreateProduct(productType, quantity); // Assert Assert.AreEqual(expectedTotal, products.Total); }
public void TestProductFactory() { var fac = new ProductFactory(); var res = fac.CreateProduct("Ram", 9.80); Assert.AreEqual(typeof(Ram), res.GetType()); Assert.AreEqual(9.80, res.Price); }
public string AddProduct(string type, double price) { Product product = productFactory.CreateProduct(type, price); productPool.Add(product); string result = $"Added {type} to pool"; return(result); }