public VendingMachineViewModel() { _repositoryFactory = new ModelFactory(null); _customerCashPurse = _repositoryFactory.CustomerPurseProxy; _vendingMachineChange = _repositoryFactory.VendingMachineChangeProxy; _goods = _repositoryFactory.GoodsProxy; }
public ContractProcessor(IContract contract, IUser user, IGoods goods, ICompany company) { _contract = contract; _user = user; _goods = goods; _company = company; }
public Model(IReadOnlyCollection <IVehicleModel> vehicleModels, IReadOnlyCollection <IVehicle> vehicles, ICityMap cityMap, IGoods goods) { VehicleModels = vehicleModels; Vehicles = vehicles; CityMap = cityMap; Goods = goods; }
public MyCabinetController(Context context, IGoods goodsRepository, ShopCart shopCart) { this.context = context; this.shopCart = shopCart; MyCabinet = new UnitOfWork_MyCabinet(context); //this.goodsRepository = goodsRepository; }
/// <summary> /// 默认构造函数 /// </summary> /// <param name="goodsService">点下物品基础信息接口</param> /// <param name="buyService">物品求购保存读取接口</param> /// <param name="accountService">帐号服务接口</param> public GoodsBuyController(IGoods goodsService, IBuyGoods buyService, IAccountService accountService) { this.goodsService = goodsService; this.buyService = buyService; this.accountService = accountService; }
/// <summary> /// 실제 계약 후 후속 작업 (notification) /// </summary> /// <param name="user"></param> /// <param name="goods"></param> /// <param name="company"></param> /// <returns></returns> /// <exception cref="NotImplementedException"></exception> public override bool PostContract(IUser user, IGoods goods, ICompany company) { //notice Console.WriteLine(user.fromObjectToJson()); Console.WriteLine(goods.fromObjectToJson()); Console.WriteLine(company.fromObjectToJson()); return(true); }
/// <summary> /// 默认构造函数 /// </summary> /// <param name="goodsService">站点下物品基础信息接口</param> /// <param name="transferService">物品转让保存读取接口</param> /// <param name="accountService">帐号服务接口</param> public GoodsTransferController(IGoods goodsService, ITransferGoods transferService, IAccountService accountService) { this.goodsService = goodsService; this.transferService = transferService; this.accountService = accountService; }
static void Main(string[] args) { Diamond diamond1 = new Diamond(); diamond1.ImportCountry = "Canada"; diamond1.Shop = "Perfect Brilliant"; diamond1.FirstName = "Duke"; diamond1.LastName = "Harmont"; diamond1.Print(); ((IWorker)diamond1).Print(); Emerald emerald1 = new Emerald(); emerald1.ImportCountry = "Greenland"; emerald1.Shop = "100%Emeralds"; emerald1.Print(); Flint flint1 = new Flint(); flint1.ImportCountry = "Belarus"; flint1.Shop = "All for travelling"; flint1.Print(); Ruby ruby1 = new Ruby(); ruby1.ImportCountry = "Kenya"; ruby1.Shop = "Smart Stones"; ruby1.Print(); Thread thread1 = new Thread(); thread1.ImportCountry = "Belarus"; thread1.Shop = "House of country"; thread1.Print(); bool a = diamond1 is PrecioiusStone; Console.WriteLine(a); Ruby Ruby2 = ruby1 as Ruby; Console.WriteLine(Ruby2); IGoods[] objects = new IGoods[3]; objects[0] = new Diamond(); objects[1] = new Ruby(); objects[2] = new Emerald(); foreach (IGoods obj in objects) { Printer.iAmPrinting(obj); } Console.ReadKey(); }
public SiteCache(ISite site, IChannelService channel, ICar car, IGoods goods, IHouse house) { this.site = site; this.channel = channel; this.car = car; //this.goods = goods;//因goods 采用二级频道 所以使用IChannelService this.house = house; }
/// <summary> /// 사용자, 상품, 연결 회사의 실제 계약 체결 /// </summary> /// <param name="user"></param> /// <param name="goods"></param> /// <param name="company"></param> /// <returns></returns> /// <exception cref="NotImplementedException"></exception> public override bool DoContract(IUser user, IGoods goods, ICompany company) { var validator = new Company.CompanyValidator(); var result = validator.Validate(company); if (!result.IsValid) { return(false); } return(true); }
/// <summary> /// 사용자 및 상품 체크 /// </summary> /// <param name="user"></param> /// <param name="goods"></param> /// <returns></returns> /// <exception cref="NotImplementedException"></exception> public override bool PreContract(IUser user, IGoods goods) { var validator = new Goods.GoodsValidator(); var result = validator.Validate(goods); if (!result.IsValid) { return(false); } return(true); }
public CityMap Generate(IGoods goods) { var warehouse = GenerateWarehouse(); var salePoints = GenerateSalePoints(10, 1000, warehouse, goods); var randomCityPlaces = GenerateCityPlaces(5, 500, warehouse); var cityPlaces = salePoints.Cast <ICityPlace>().Union(randomCityPlaces).Union(new[] { warehouse }).ToHashSet(); var roads = GenerateCityRoads(cityPlaces); return(new CityMap( cityPlaces, roads.Cast <ICityRoad>().ToHashSet() )); }
public VendingMachineViewPresenter(IVendingMachineView view, IModelFactory model) { _view = view; _repositoryFactory = model; _customerCashPurseRepository = _repositoryFactory.CustomerPurseProxy; _customerCachButtonControlPresenter = _presenterFactory.CreateCustomerCashButtonControlPresenter(_view.CustomerCashButtonControlView, _customerCashPurseRepository); _vendingMachineChangeRepository = _repositoryFactory.VendingMachineChangeProxy; _vendingMachineChangeCashButtonControlPresenter = _presenterFactory.CreateVendingMachineChangeCashButtonControlPresenter(_view.VendingMachineChangeCashButtonControlView, _vendingMachineChangeRepository); _goodsRepository = _repositoryFactory.GoodsProxy; _goodsButtonControlPresenter = _presenterFactory.CreateGoodsButtonControlPresenter(_view.GoodsButtonControlView, _goodsRepository); _fillingCupProgressBarControlPresenter = _presenterFactory.CreateFillingCupProgressBarControlPresenter(_view.FillingCupProgressBarControlView); _view.Shown += _view_Shown; }
public void AddToShop(IGoods product) { List<IGoods> tempList = new List<IGoods>(); tempList.AddRange(goodsList); if (goodsList.Count > 0) foreach (var t in tempList) { if (t.Title == product.Title && !t.Status) goodsList.RemoveAt(tempList.IndexOf(t)); } goodsList.Add(product); }
static void Main(string[] args) { var goods = new IGoods[] { new DairyProducts("Milk", 1.20m, 1, Unit.LITER), new DairyProducts("Yoghurt", 0.80m, 250, Unit.GRAMM), new MeatProducts("T-Bone Steak", 26.90m, 1, Unit.KILOGRAMM), new MeatProducts("Minced Meat", 6.90m, 1, Unit.KILOGRAMM) }; foreach (var x in goods) { Console.WriteLine($"Item: {x.Label, -15} Price: {x.Price, 5}"); } }
public void AddGoods(string GoodsTitle, string Category, string Type, double PurchacePrice, double RetailPrice, string StoreTitle) { List <object> goodsParameters = new List <object> { GoodsTitle, Category, Type, PurchacePrice, RetailPrice }; IGoods newGoods = IoCContainer.ResolveObject(typeof(IGoods), goodsParameters); List <IStore> availableStores = GetAvailableStores(Category, Type); foreach (IStore store in availableStores) { if (store.title == StoreTitle) { repository.AddGoodsToDb(newGoods, store); store.PutGoodsHere(newGoods); } } }
public IGoods Create(string category, int quantity, string name, double price) { IGoods good = Exemptions.Contains(category) ? new TaxExemptGood() : new Goods(); good.Quantity = quantity; good.Name = name; good.Price = price; if (good.Name.Length >= 8 && good.Name.Contains("imported")) { good.Imported = true; } else { good.Imported = false; } return(good); }
public void AddToShop(IGoods product) { List <IGoods> tempList = new List <IGoods>(); tempList.AddRange(goodsList); if (goodsList.Count > 0) { foreach (var t in tempList) { if (t.Title == product.Title && !t.Status) { goodsList.RemoveAt(tempList.IndexOf(t)); } } } goodsList.Add(product); }
public void Create_Returns_TaxExemptGood_Given_Valid_TaxExemptGoodInfo() { //Arrange string category = "books"; int quantity = 1; string name = "cook book"; double price = 12.15; IGoodsFactory target = new GoodsFactory(); //Act IGoods actual = target.Create(category, quantity, name, price); //Assert Assert.AreEqual(actual.Name, name); Assert.AreEqual(actual.Price, price); Assert.AreEqual(actual.Quantity, quantity); Assert.IsInstanceOf <TaxExemptGood>(actual, typeof(TaxExemptGood).ToString()); }
public void Create_Returns_NonImportedGood_Given_Valid_GoodsInfo() { //Arrange string category = "general"; int quantity = 1; string name = "music CD"; double price = 15.50; IGoodsFactory target = new GoodsFactory(); //Act IGoods actual = target.Create(category, quantity, name, price); //Assert Assert.AreEqual(actual.Name, name); Assert.AreEqual(actual.Price, price); Assert.AreEqual(actual.Quantity, quantity); Assert.IsInstanceOf <Goods>(actual, typeof(Goods).ToString()); }
public void Create_Returns_ImportedTaxExemptGood_Given_Valid_ImportedTaxExemptGoodInfo() { //Arrange string category = "food"; int quantity = 1; string name = "imported chocolate"; double price = 10.50; IGoodsFactory target = new GoodsFactory(); //Act IGoods actual = target.Create(category, quantity, name, price); //Assert Assert.AreEqual(actual.Name, name); Assert.AreEqual(actual.Price, price); Assert.AreEqual(actual.Quantity, quantity); Assert.AreEqual(actual.Imported, true); Assert.IsInstanceOf <TaxExemptGood>(actual, typeof(TaxExemptGood).ToString()); }
private HashSet <SalePoint> GenerateSalePoints( int count, double maxDistanceFromWarehouse, IWarehouse warehouse, IGoods goods) { var random = new Random(); return(Enumerable.Range(0, count).Select(i => { var r = maxDistanceFromWarehouse * Math.Sqrt(random.NextDouble()); var theta = random.NextDouble() * 2 * Math.PI; return new SalePoint( new Coordinate(warehouse.Coordinates.X + r * Math.Cos(theta), warehouse.Coordinates.Y + r * Math.Sin(theta)), VehicleType.Passenger | VehicleType.BigTruck, goods ); }).ToHashSet()); }
public void NewAddToShop(IGoods product) { List <IGoods> tempList = new List <IGoods>(); tempList.AddRange(Favourites); AddToShop(product); foreach (var t in tempList) { if (t.Title == product.Title && product.Status) { goodsArrived += new NewGoods(Handler); RemoveFromFavourites(t); AddToBasket(product, 1); } } NewGoodsArrived(); }
public void NewAddToShop(IGoods product) { List<IGoods> tempList = new List<IGoods>(); tempList.AddRange(Favourites); AddToShop(product); foreach (var t in tempList) if (t.Title == product.Title && product.Status) { goodsArrived += new NewGoods(Handler); RemoveFromFavourites(t); AddToBasket(product, 1); } NewGoodsArrived(); }
public void AddToBasket(IGoods product, double quantity) { Basket.Add(product, quantity); Bill += product.Price * quantity; }
public void RemoveFromFavourites(IGoods product) { Favourites.Remove(product); }
public void RemoveFromBasket(IGoods product) { Bill -= product.Price * Basket[product]; Basket.Remove(product); }
private static PackedBunches PassablyPack(IList <IGoods> goodsList, int knapsackSize, int minPackSize) { int zeroCount = Int32.MaxValue; int minGoodsSize = Int32.MaxValue; int toolSize = 0; foreach (IGoods item in goodsList) { if (zeroCount > 0) { int z = 0; int size = item.Size; while (size > 0 && size % 10 == 0) { size = size / 10; z = z + 1; } if (zeroCount > z) { zeroCount = z; } } if (minGoodsSize > item.Size) { minGoodsSize = item.Size; } toolSize = toolSize + item.Size; } if (knapsackSize >= toolSize) { return(minPackSize <= toolSize ? new PackedBunches(toolSize, goodsList) : null); } if (minPackSize < minGoodsSize) { minPackSize = minGoodsSize; } int precision = (int)Math.Pow(10, zeroCount); int knapsackSizeP = knapsackSize / precision; if (knapsackSizeP >= ArrayMaxSize) { return(PassablyPackBig(goodsList, knapsackSize, minPackSize)); } int minPackSizeP = minPackSize / precision; int minSizeP = minGoodsSize / precision; int[] matrixL = new int[knapsackSizeP + 1]; int[] matrixR = new int[knapsackSizeP + 1]; Dictionary <int, SortedSet <int> > putinSizeDictionary = new Dictionary <int, SortedSet <int> >(goodsList.Count); for (int i = 0; i < goodsList.Count; i++) { IGoods goods = goodsList[i]; SortedSet <int> putinSizeList = new SortedSet <int>(); int goodsSizeP = goods.Size / precision; for (int s = minSizeP; s <= knapsackSizeP; s++) { int marginSizeP = s - goodsSizeP; //s规格的背包放入goods后的余量是marginSize if (marginSizeP >= 0) //s规格的背包放得下goods { int value = matrixL[marginSizeP] + goods.Value; //与前轮(第0...i-1件)规划得到的marginSize规格的背包合拼 if (value > matrixL[s]) //放下后的价值更高 { matrixR[s] = value; putinSizeList.Add(s); continue; } } matrixR[s] = matrixL[s]; } int[] matrixT = matrixL; matrixL = matrixR; matrixR = matrixT; putinSizeDictionary.Add(i, putinSizeList); } List <IGoods> result = new List <IGoods>(); int canPackSizeP; for (int ii = goodsList.Count - 1; ii >= 0; ii--) { SortedSet <int> putinSizeList = putinSizeDictionary[ii]; if (putinSizeList.Count == 0) { continue; } for (int s = knapsackSizeP; s >= minPackSizeP; s--) { if (putinSizeList.Contains(s)) { result.Clear(); IGoods goods = goodsList[ii]; result.Add(goods); canPackSizeP = s - goods.Size / precision; for (int i = ii - 1; i >= 0; i--) { if (putinSizeDictionary[i].Contains(canPackSizeP)) { goods = goodsList[i]; result.Add(goods); canPackSizeP = canPackSizeP - goods.Size / precision; if (canPackSizeP < minSizeP) { break; } } } if (s - canPackSizeP >= minPackSizeP) { return(new PackedBunches((s - canPackSizeP) * precision, result)); } } } } result.Clear(); canPackSizeP = knapsackSizeP; for (int i = goodsList.Count - 1; i >= 0; i--) { if (putinSizeDictionary[i].Contains(canPackSizeP)) { IGoods goods = goodsList[i]; result.Add(goods); canPackSizeP = canPackSizeP - goods.Size / precision; if (canPackSizeP < minSizeP) { break; } } } return(new PackedBunches((knapsackSizeP - canPackSizeP) * precision, result)); }
public void PutGoodsHere(IGoods Goods) { goods.Add(Goods); }
static void Main(string[] args) { Diamond diamond1 = new Diamond(); diamond1.ImportCountry = "Canada"; diamond1.Shop = "Perfect Brilliant"; diamond1.FirstName = "Duke"; diamond1.LastName = "Harmont"; diamond1.good = "Diamond"; diamond1.PRice = 1000; diamond1.Print(); ((IWorker)diamond1).Print(); Emerald emerald1 = new Emerald(); emerald1.ImportCountry = "Greenland"; emerald1.Shop = "100%Emeralds"; emerald1.good = "Emerald"; emerald1.PRice = 500; emerald1.Print1(); emerald1.Print(); Flint flint1 = new Flint(); flint1.ImportCountry = "Belarus"; flint1.good = "Flint"; flint1.PRice = 300; flint1.Shop = "All for travelling"; flint1.Print(); Ruby ruby1 = new Ruby(); ruby1.ImportCountry = "Kenya"; ruby1.good = "Ruby"; ruby1.PRice = 800; ruby1.Shop = "Smart Stones"; ruby1.Print(); Thread thread1 = new Thread(); thread1.ImportCountry = "Belarus"; thread1.good = "Thread"; thread1.PRice = 50; thread1.Shop = "House of country"; thread1.Print(); bool a = diamond1 is PrecioiusStone; Console.WriteLine(a); Ruby Ruby2 = ruby1 as Ruby; Console.WriteLine(Ruby2); IGoods[] objects = new IGoods[3]; objects[0] = new Diamond(); objects[1] = new Ruby(); objects[2] = new Emerald(); foreach (IGoods obj in objects) { Printer.iAmPrinting(obj); } Console.WriteLine(); Weight op; op = Weight.Diamond; Console.WriteLine(op); Console.WriteLine(); string k = diamond1.good; Console.WriteLine("The Necklace consists of: "); Necklace necklake = new Necklace(); necklake.Add(flint1); necklake.Add(diamond1); necklake.Add(thread1); necklake.Add(ruby1); necklake.Add(emerald1); necklake.show(); controller control = new controller(); control.Weight(necklake); controller sort = new controller(); sort.Sort(necklake); necklake.show(); Console.ReadKey(); }
internal MockGoodsRepository(int quantity, int price) { (_proxy = new ModelFactory(null).GoodsProxy).Repo.Reinit(Dummies.DummyInitGoods(quantity, price)); }
public override bool CancelContract(IUser user, IGoods goods, ICompany company) { return(true); }
public override bool PreContract(IUser user, IGoods goods) { return(true); }
public GoodsBLL() : base(typeName) { iGoods = (IGoods)idal; }
public void AddToFavourites(IGoods product) { Favourites.Add(product); }
public HomeController(IShop shop, IGoods goods) { this.shopRepository = shop; this.goodsRepository = goods; }
public ShopCartController(IGoods goodsRepository, ShopCart shopCart) { this.shopCart = shopCart; this.goodsRepository = goodsRepository; }
public GoodsButtonControlPresenter(IGoodsButtonControlView view, IGoods repository) { _repository = repository; _view = view; _view.Shown += _view_Shown; }