private void button4_Click(object sender, EventArgs e) { Macbook m = new Macbook { nume = new Nume { Value = cB_nume.Text }, diagonala = new Diagonala { Value = Convert.ToDouble(cB_diagonala.Text) }, tipProcesor = new TipProcesor { Value = cB_procesor.Text }, fregventa = new Fregventa { Value = Convert.ToDouble(cB_fregventa.Text) }, ram = new RAM { Value = Convert.ToDouble(cB_ram.Text) }, ssd = new SSD { Value = Convert.ToDouble(cB_ssd.Text) }, an = new An { Value = Convert.ToDouble(cB_an.Text) } }; tB_pret.Text = CalcPrice(m).ToString("F0"); }
static void Main(string[] args) { Laptop asusZenbook = new AsusZenbook(); Laptop macbookAir = new Macbook(); asusZenbook.TurnOn(); macbookAir.TurnOn(); }
private double CalcPrice(Macbook mackbook) { foreach (var neuron in _hiddenLayer) { neuron._inputs = mackbook.ToDoubleArray(); } _outputLayer._inputs = _hiddenLayer.ToDoubleArray(); return(_min + ((_max - _min) * _outputLayer.output)); }
public void Run() { #region Get Delivery cost values from config. var costPerDelivery = _config.GetValue <double>("Delivery:CostPerDelivery"); var costPerProduct = _config.GetValue <double>("Delivery:CostPerProduct"); var fixedCost = _config.GetValue <double>("Delivery:FixedCost"); #endregion #region Category and product creation var computerCategory = new Category.Category("Computer"); var phoneCategory = new Category.Category("Phone"); var ipone = new Iphone(7500, phoneCategory); var macbook = new Macbook(18500, computerCategory); #endregion #region Shopping cart creation IShoppingCart cart = new Cart.ShoppingCart(new DeliveryCostCalculator(costPerDelivery, costPerProduct, fixedCost)); cart.AddItem(ipone, 10); cart.AddItem(macbook, 5); #endregion #region Get campaign type from CampaignFactory with CampaignTypes enum. CampaignFactory campaignFactory = new CampaignFactory(); var campaign2 = campaignFactory.Get(computerCategory, 1500, 1, CampaignTypes.Amount); var campaign3 = campaignFactory.Get(phoneCategory, 2, 1, CampaignTypes.Rate); #endregion #region Apply first campaign discount then coupon cart.ApplyDiscounts(campaign2, campaign3); CouponFactory couponFactory = new CouponFactory(); var coupon = couponFactory.Get(500, 150, CouponTypes.Amount); cart.ApplyCoupon(coupon); #endregion Console.WriteLine(cart.Print()); Console.ReadLine(); }
public static MackbookCodifDataView ToMacbookCofifDataView(this Macbook data) { return(new MackbookCodifDataView { Nume = data.nume.NormalizedValue, Diagonala = data.diagonala.NormalizedValue, An = data.an.NormalizedValue, Fregventa = data.fregventa.NormalizedValue, Pret = data.pret.NormalizedValue, Ram = data.ram.NormalizedValue, // Rezolutie = data.rezolutie.NormalizedValue, Ssd = data.ssd.NormalizedValue, TipProcesor = data.tipProcesor.NormalizedValue }); }
public static MacbookDataView ToMacbookDataView(this Macbook data) { return(new MacbookDataView { Nume = data.nume.Value, Diagonala = data.diagonala.Value.ToString(), An = data.an.Value.ToString(), Fregventa = data.fregventa.Value.ToString(), Pret = data.pret.Value.ToString(), Ram = data.ram.Value.ToString(), // Rezolutie = data.rezolutie.Value, Ssd = data.ssd.Value.ToString(), TipProcesor = data.tipProcesor.Value }); }
public static double[] ToDoubleArray(this Macbook value) { return(new double[] { value.nume.NormalizedValue, value.diagonala.NormalizedValue, value.tipProcesor.NormalizedValue, value.fregventa.NormalizedValue, value.ram.NormalizedValue, value.ssd.NormalizedValue, value.an.NormalizedValue, }); // value.rezolutie.NormalizedValue}; }
public void ProductMacbook_ShouldArgumentOutOfRangeException_WhenPriceIsLessThanOrEqualZero(double price) { var macbook = new Macbook(price, phoneCategory); Assert.Throws <ArgumentOutOfRangeException>(() => macbook.Price); }
public void ProductMacbook_ShouldArgumentNullException_WhenTitleIsNull(string title) { var macbook = new Macbook(18500, computerCategory, title); Assert.Throws <ArgumentNullException>(() => macbook.ProductTitle); }
private void LoadCsv() { using (var reader = new StreamReader(_file)) { _data.Clear(); _dataView.Clear(); _dataCodifView.Clear(); _tapLines.Clear(); int i = 0; if (!reader.EndOfStream) { reader.ReadLine();// header } while (!reader.EndOfStream) { var line = reader.ReadLine(); var values = line.Split(','); Macbook m = new Macbook { nume = new Nume { Value = values[0] }, diagonala = new Diagonala { Value = Convert.ToDouble(values[1]) }, tipProcesor = new TipProcesor { Value = values[2] }, fregventa = new Fregventa { Value = Convert.ToDouble(values[3]) }, ram = new RAM { Value = Convert.ToDouble(values[4]) }, ssd = new SSD { Value = Convert.ToDouble(values[5]) }, an = new An { Value = Convert.ToDouble(values[6]) }, //rezolutie = new Rezolutie { Value = values[7] }, pret = new Pret { Value = Convert.ToDouble(values[7]) }, testare = Convert.ToBoolean(values[8]) }; _data.Add(m); _dataView.Add(m.ToMacbookDataView()); _dataCodifView.Add(m.ToMacbookCofifDataView()); if (m.testare) { _tapLines.Add(i); } ++i; } } var binding = new BindingSource(); binding.DataSource = _dataView; dGW_date.DataSource = binding; var bindingCod = new BindingSource(); bindingCod.DataSource = _dataCodifView; dGW_codif.DataSource = bindingCod; //tap lines DataGridViewCellStyle tapped = new DataGridViewCellStyle(); tapped.BackColor = Color.Orange; tapped.ForeColor = Color.White; }