private void InitContents( FruitType type ) { Food item = null; byte count = (byte)Utility.RandomMinMax( 10, 30 ); for( byte i = 0; i < count; i++ ) { switch( type ) { default: case FruitType.Apples: item = new Apple(); break; case FruitType.Bananas: item = new Banana(); break; case FruitType.Bread: item = new BreadLoaf(); break; case FruitType.Gourds: item = new Gourd(); break; case FruitType.Grapes: item = new Grapes(); break; case FruitType.Lemons: item = new Lemon(); break; case FruitType.Tomatoes: item = new Tomato(); break; case FruitType.Vegetables1: case FruitType.Vegetables2: case FruitType.Vegetables3: { switch( Utility.Random( 4 ) ) { case 0: item = new Carrot(); break; case 1: item = new Onion(); break; case 2: item = new Pumpkin(); break; case 3: item = new Gourd(); break; } break; } } if( item != null ) DropItem( item ); } }
public Supplier() { // Generate Random Name NameGenerator nameGenerator = new NameGenerator(); this.name = nameGenerator.GenRandomLastName(); // // Generate Random Starting Inventory // int minStartingQuantity = 5; int maxStartingQuantity = 15; System.Threading.Thread.Sleep(100); Random random = new Random(); // Lemons int generateQuantity = random.Next(minStartingQuantity, maxStartingQuantity); for (int i = 0; i < generateQuantity; i++) { lemonInventory.add(new Lemon()); } // Sugar generateQuantity = random.Next(minStartingQuantity, maxStartingQuantity); for (int i = 0; i < generateQuantity; i++) { Ingredient lemon = new Lemon(); this.lemonInventory.add(lemon); } // Sugar generateQuantity = random.Next(1,15); for (int i = 0; i < generateQuantity; i++) { Ingredient sugar = new Sugar(); sugarInventory.add(sugar); } // Ice generateQuantity = random.Next(minStartingQuantity, maxStartingQuantity); for (int i = 0; i < generateQuantity; i++) { Ingredient ice = new Ice(); iceInventory.add(ice); } // Cups generateQuantity = random.Next(minStartingQuantity, maxStartingQuantity); for (int i = 0; i < generateQuantity; i++) { Ingredient cups = new Cups(); cupInventory.add(cups); } // Generate Random Price List ?? // STUB Hard Code STUB int basePrice = 1; int minVariance = 10; int maxVariance = 100; this.lemonSalePrice = basePrice + (random.Next(minVariance, maxVariance)/100f); this.sugarSalePrice = basePrice + (random.Next(minVariance, maxVariance)/100f); this.iceSalePrice = basePrice + (random.Next(minVariance, maxVariance)/100f); this.cupSalePrice = basePrice + (random.Next(minVariance, maxVariance)/100f); // Generate Random Cash on Hand int minStartingCash = 600; int maxStartingCash = 1400; this.cashOnHand = random.Next(minStartingCash, maxStartingCash); }
// // UPDATE METHODS - UPDATE PURCHASES, PRICES, SPOILAGE // public void update() { // Update Spoilage of inventory this.lemonInventory.update(); this.sugarInventory.update(); // this.iceInventory.update(); // Ice has a variable spoilage that is not programmed in yet // this.cupInventory.update(); // Cups do not spoil // // Purchase new inventory based off the day's sales // int inventoryBumpForSales = 2; // For each lemon sold, but two more // Lemons for (int i = 0; i < lemonsSoldToday; i++) { for (int j = 0; j < inventoryBumpForSales; j++) { Ingredient lemon = new Lemon(); lemonInventory.add(lemon); cashOnHand -= lemonSalePrice/2; } } // Sugar for (int i = 0; i < sugarSoldToday; i++) { for (int j = 0; j < inventoryBumpForSales; j++) { Ingredient sugar = new Sugar(); sugarInventory.add(sugar); cashOnHand -= sugarSalePrice / 2; } } // Ice for (int i = 0; i < iceSoldToday; i++) { for (int j = 0; j < inventoryBumpForSales; j++) { Ingredient ice = new Ice(); iceInventory.add(ice); cashOnHand -= iceSalePrice / 2; } } // Cup for (int i = 0; i < cupSoldToday; i++) { for (int j = 0; j < inventoryBumpForSales; j++) { Ingredient cup = new Cups(); cupInventory.add(cup); cashOnHand -= cupSalePrice / 2; } } // // Update Prices based off the day's sales. // // Lemons if (this.lemonsSoldToday == 0) { this.lemonSalePrice -= .01f; } else { this.lemonSalePrice += .01f * this.lemonsSoldToday; } // Sugar if (this.sugarSoldToday == 0) { this.sugarSalePrice -= .01f; } else { this.sugarSalePrice += .01f * this.sugarSoldToday; } // Ice if (this.iceSoldToday == 0) { this.iceSalePrice -= .01f; } else { this.iceSalePrice += .01f * this.iceSoldToday; } // Cups if (this.cupSoldToday == 0) { this.cupSalePrice -= .01f; } else { this.cupSalePrice += .01f * this.cupSoldToday; } // // Calculate Todays Fixed Operating Cost // float dailyHardCost = 50f; this.cashOnHand -= dailyHardCost; // // Reset Daily Sales Count // this.lemonsSoldToday = 0; this.sugarSoldToday = 0; this.iceSoldToday = 0; this.cupSoldToday = 0; }
/// <summary> /// 加载动作上下文处理器到模板 /// </summary> /// <returns></returns> public void LoadActionsContext() { string styledir = Lemon.GetCSFRootDirectory() + @"\Actions\"; this.contexttemplates = Lemon.FindInstanceFromDirectory <IActionContext>(styledir, false); }
/// <summary> /// 创建动作 /// </summary> /// <param name="ActionName">动作名称</param> /// <param name="Type">动作类型</param> /// <param name="InvokeObject">调用的对象</param> /// <param name="InvokeProcessor">对象处理者委托</param> /// <param name="Performer">注销动作时的回调函数</param> /// <returns></returns> public bool CreateAction(string ActionName, ActionType Type, object InvokeObject, Delegate InvokeProcessor, ActionPerformer Performer = null) { bool iscmp = false; IAction newAction = new Action(InvokeObject, ActionName, Type, InvokeProcessor, Performer); //查找是否已经存在上下文 var f = this.contexts.Find(delegate(IActionContext ac) { return(ac.ContextProcessType == Lemon.GetObjType(InvokeObject)); }); if (f == null) { //不存在则创建新的 if (this.contexttemplates.Count > 0) { //创建新的上下文 IActionContext newAc = Lemon.GetInstance <IActionContext>(Lemon.GetObjType(this.MatcherContextTemplate(newAction))); newAc.ContextProcessType = Lemon.GetObjType(InvokeObject); f = newAc; //加入上下文实例的集合 this.contexts.Add(f); } } if (f != null) { //判断是否是单一动作 if (newAction.Type == Lemonade.Frame.Running.ActionType.Single) { this.Remove(newAction.InvokeObject, newAction.ActionName, ActionType.Single); } else { f.RemoveAction(newAction); } f.AddAction(newAction); iscmp = true; } return(iscmp); }
public GiftBag(bool nice) { Item item = null; Hue = Utility.RandomList(32, 64, 2301); if (nice) { Name = "Happy Holidays!"; DropItem(MakeNewbie(new WristWatch())); if (Utility.RandomBool()) { item = new Cake(); item.ItemID = 4164; item.Hue = 432; item.Name = "fruit cake"; DropItem(MakeNewbie(item)); } else { DropItem(MakeNewbie(new CheesePizza())); } if (Utility.RandomBool()) { DropItem(MakeNewbie(new BeverageBottle(BeverageType.Champagne))); } else { DropItem(MakeNewbie(new BeverageBottle(BeverageType.EggNog))); } switch (Utility.Random(7)) { default: case 0: DropItem(MakeNewbie(new Apple())); break; case 1: DropItem(MakeNewbie(new Pear())); break; case 2: DropItem(MakeNewbie(new Bananas())); break; case 3: DropItem(MakeNewbie(new Dates())); break; case 4: DropItem(MakeNewbie(new Coconut())); break; case 5: DropItem(MakeNewbie(new Peach())); break; case 6: DropItem(MakeNewbie(new Grapes())); break; } item = new Goblet(); item.Name = "a champagne glass"; item.Hue = 71; DropItem(MakeNewbie(item)); item = new Goblet(); item.Name = "a champagne glass"; item.Hue = 34; DropItem(MakeNewbie(item)); DropItem(MakeNewbie(new FireworksWand(100))); item = new Item(5359); item.Hue = Utility.RandomList(32, 64, 2301); item.Name = "Seasons Greetings"; DropItem(MakeNewbie(item)); //DropItem( new IrinaFlowers() ); } else { Name = "You were naughty this year!"; item = new Bacon(); item.ItemID = 4164; // spam DropItem(MakeNewbie(item)); DropItem(MakeNewbie(new Coal())); if (Utility.RandomBool()) { item = new Lemon(); item.Name = "Sour attitude"; DropItem(item); } item = new Kindling(); item.Name = "switches"; DropItem(item); // not newbied... item = new Item(5359); item.Hue = Utility.RandomList(32, 64, 2301); item.Name = "Maybe next year you will get a nicer gift."; DropItem(MakeNewbie(item)); } }
public void RunCache() { Lemon.SetLayout("框架布局分栏B"); }
/// <summary> /// 实例化并注册对象 /// </summary> public virtual void Regedit() { this.systemFrm = Lemon.GetInstance <ILoadSystem>(typeof(FrmMain)); this.displayFrm = Lemon.GetInstance <ILoadDisplay>(typeof(Frm_Welcome), this); this.systemFrm.Regidit(this.displayFrm); }
/// <summary> /// 实现接口方法,运行缓存,当模块在框架中已经存在实例是,框架默认运行的方法 /// </summary> public void RunCache() { Lemon.SendMsgNote("再次运行"); }
private void button2_Click(object sender, EventArgs e) { Lemon.RemoveMsgProcess(process); }
private void button1_Click(object sender, EventArgs e) { process = new CustomErrorProcess(this); Lemon.AddMsgProcess(process); }
public void TaxProduceEqualsZero() { //Arrange Ingredient recipe = new Lemon(null, DEFAULT_UNIT_SIZE); Ingredient nonProduce = new ChickenBreast(null, DEFAULT_UNIT_SIZE); //Assert Assert.IsTrue(recipe.getTax() == 0); Assert.IsFalse(nonProduce.getTax() == 0); //Act recipe = new ChickenBreast(recipe, DEFAULT_UNIT_SIZE); //Assert Assert.IsTrue(recipe.getTax() == nonProduce.getTax()); }
public void SubtractServingCannotMakeSizeNegative() { //Arrange Ingredient aboveZero = new Lemon(null, DEFAULT_UNIT_SIZE); Ingredient atZero = new Garlic(null, DEFAULT_UNIT_SIZE); Ingredient belowZero = new Corn(null, DEFAULT_UNIT_SIZE); //Assert Assert.IsTrue(aboveZero.Units == DEFAULT_UNIT_SIZE); Assert.IsTrue(atZero.Units == DEFAULT_UNIT_SIZE); Assert.IsTrue(belowZero.Units == DEFAULT_UNIT_SIZE); //Act aboveZero.subtractServing(DEFAULT_UNIT_SIZE - 0.1); atZero.subtractServing(DEFAULT_UNIT_SIZE); belowZero.subtractServing(DEFAULT_UNIT_SIZE + 0.1); //Assert Assert.IsTrue(aboveZero.Units > 0.0); Assert.IsTrue(atZero.Units == 0.0); Assert.IsTrue(belowZero.Units >= 0.0); }
/// <summary> /// 数据转换到控件 /// </summary> protected ToolsBarSetting DataConvterCtrl(ToolsBarData BarData) { string pathbase = Lemon.GetCSFRootDirectory(); ToolsBarSetting result = new ToolsBarSetting(); //工具栏 foreach (TBar tbar in BarData.Bars) { ToolsBar newBar = new ToolsBar(); newBar.ParentFormName = tbar.ParentFormName; newBar.ToolsBarCode = tbar.ToolsBarCode; newBar.ToolsBarName = tbar.ToolsBarName; result.Bars.Add(newBar); } //按钮 foreach (TButton tbtn in BarData.Buttons) { ToolsButton newBtn = new ToolsButton(); newBtn.AssemblyPath = pathbase + tbtn.Assembly; newBtn.FullClassName = tbtn.FullClassName; newBtn.GroupName = tbtn.GroupName; newBtn.ItemImage = pathbase + tbtn.ItemImage; newBtn.ItemIndex = tbtn.ItemIndex; newBtn.Title = tbtn.Title; newBtn.ToolsBarCode = tbtn.ToolsBarCode; IControlToolsButton elm = Lemon.GetInstance <IControlToolsButton>(newBtn.AssemblyPath, newBtn.FullClassName); if (elm != null) { newBtn.UIElement = elm; result.Buttons.Add(newBtn); } else { Lemon.SendMsgDebug("配置的工具栏按钮" + newBtn.ToolsBarCode + "没有实现IUIElement接口"); } } //下拉框 foreach (TComboBox tcb in BarData.ComboBoxs) { ToolsComboBox newCb = new ToolsComboBox(); newCb.GroupName = tcb.GroupName; newCb.ItemIndex = tcb.ItemIndex; newCb.ToolsBarCode = tcb.ToolsBarCode; IControlToolsComoBoxItem cbelm = Lemon.GetInstance <IControlToolsComoBoxItem>(tcb.Assembly, tcb.FullClassName); if (cbelm != null) { newCb.UIElement = cbelm; } else { Lemon.SendMsgDebug("配置的工具栏下拉框" + newCb.ToolsBarCode + "没有实现IUIElement接口"); } foreach (TComboBoxItem ti in tcb.Items) { ToolsComboBoxItem newItem = new ToolsComboBoxItem(); ti.Assembly = pathbase + ti.Assembly; newItem.ItemData = ti; IControlToolsComoBoxItem elm = Lemon.GetInstance <IControlToolsComoBoxItem>(ti.Assembly, ti.FullClassName); if (elm != null) { newItem.UIElement = elm; newCb.Items.Add(newItem); } else { Lemon.SendMsgDebug("配置的工具栏下拉框的选项" + ti.Title + "没有实现IUIElement接口"); } } result.ComboBoxs.Add(newCb); } //分栏 foreach (TSeparator tsep in BarData.Separator) { ToolsSeparator newSep = new ToolsSeparator(); newSep.GroupName = tsep.GroupName; newSep.ItemIndex = tsep.ItemIndex; newSep.ToolsBarCode = tsep.ToolsBarCode; result.Separator.Add(newSep); } return(result); }