private void button1_Click(object sender, EventArgs e) { message.Text = ""; Environment.Reset((int)population.Value, (double)base_cost.Value, (double)base_salary.Value, (int)eq_state.Value); spa = new Spa((int)start_square.Value, (int)start_service.Value, (int)start_staff.Value, (int)start_equipment.Value); month = 1; clients.ChartAreas[0].AxisX.Minimum = 0; clients.ChartAreas[0].AxisX.Maximum = 12; qual_capacity.ChartAreas[0].AxisX.Minimum = 0; qual_capacity.ChartAreas[0].AxisX.Maximum = 12; cost_price.ChartAreas[0].AxisX.Minimum = 0; cost_price.ChartAreas[0].AxisX.Maximum = 12; staff_equip.ChartAreas[0].AxisX.Minimum = 0; staff_equip.ChartAreas[0].AxisX.Maximum = 12; profit_chart.ChartAreas[0].AxisX.Minimum = 0; profit_chart.ChartAreas[0].AxisX.Maximum = 12; period.Text = Environment.period.ToString(); clients_income.Text = Environment.customers_income.ToString(); served.Text = spa.served.ToString(); quality.Text = spa.service_quality.ToString(); capacity.Text = spa.service_capacity.ToString(); capacity.Text = spa.service_capacity.ToString(); cost.Text = Service.cost.ToString(); equipment.Text = spa.equipment.Count.ToString(); staff.Text = spa.staff.Count.ToString(); clients.Series.Clear(); clients.Series.Add("income"); clients.Series.Add("served"); clients.Series[0].Points.AddXY(month, Environment.customers_income); clients.Series[1].Points.AddXY(month, spa.served); qual_capacity.Series.Clear(); qual_capacity.Series.Add("quality"); qual_capacity.Series.Add("capacity"); qual_capacity.Series[0].Points.AddXY(month, spa.service_quality); qual_capacity.Series[1].Points.AddXY(month, spa.service_capacity); cost_price.Series.Clear(); cost_price.Series.Add("cost"); cost_price.Series.Add("price"); cost_price.Series[0].Points.AddXY(month, Service.cost); cost_price.Series[1].Points.AddXY(month, spa.GetAvgServicePrice()); staff_equip.Series.Clear(); staff_equip.Series.Add("staff"); staff_equip.Series.Add("equipment"); staff_equip.Series[0].Points.AddXY(month, spa.staff.Count); staff_equip.Series[1].Points.AddXY(month, spa.equipment.Count); profit_chart.Series[0].Points.Clear(); profit_chart.Series[0].Points.AddXY(month, spa.profit); profit_month.Series[0].Points.Clear(); timer1.Enabled = true; pause.Enabled = true; skip_month.Enabled = true; }
private void timer1_Tick(object sender, EventArgs e) { Environment.SendPotentialCustomer(spa); if (Environment.period % 240 == 0) { month++; profit_chart.Series[0].Points.AddXY(month, spa.profit); qual_capacity.Series[0].Points.AddXY(month, spa.service_quality); qual_capacity.Series[1].Points.AddXY(month, spa.service_capacity); cost_price.Series[0].Points.AddXY(month, Service.cost); cost_price.Series[1].Points.AddXY(month, spa.GetAvgServicePrice()); profit_month.Series[0].Points.Clear(); if (!spa.NextMonth()) { stop(); return; } { } if (month > 12) { clients.ChartAreas[0].AxisX.Minimum = month - 8; clients.ChartAreas[0].AxisX.Maximum = month + 4; qual_capacity.ChartAreas[0].AxisX.Minimum = month - 8; qual_capacity.ChartAreas[0].AxisX.Maximum = month + 4; cost_price.ChartAreas[0].AxisX.Minimum = month - 8; cost_price.ChartAreas[0].AxisX.Maximum = month + 4; staff_equip.ChartAreas[0].AxisX.Minimum = month - 8; staff_equip.ChartAreas[0].AxisX.Maximum = month + 4; profit_chart.ChartAreas[0].AxisX.Minimum = month - 8; profit_chart.ChartAreas[0].AxisX.Maximum = month + 4; } } else { if (!spa.NextHour()) { stop(); return; } } clients.Series[0].Points.AddXY(month, Environment.customers_income); clients.Series[1].Points.AddXY(month, spa.served); staff_equip.Series[0].Points.AddXY(month, spa.staff.Count); staff_equip.Series[1].Points.AddXY(month, spa.equipment.Count); profit_month.Series[0].Points.AddXY((int)(Environment.period / 8), spa.profit); period.Text = Environment.period.ToString(); clients_income.Text = Environment.customers_income.ToString(); served.Text = spa.served.ToString(); quality.Text = Math.Round(spa.service_quality, 2).ToString(); capacity.Text = Math.Round(spa.service_capacity, 2).ToString(); cost.Text = Math.Round(Service.cost, 2).ToString(); equipment.Text = spa.equipment.Count.ToString(); staff.Text = spa.staff.Count.ToString(); profit.Text = Math.Round(spa.profit, 2).ToString(); price.Text = Math.Round(spa.GetAvgServicePrice(), 2).ToString(); }
public static void SendPotentialCustomer(Spa s) { Customer n; int limit = (int)(Math.Log(population) * 0.7 * s.service_capacity / Math.Log(s.GetAvgServicePrice())) + 1; for (int i = 0; i < limit + rand.Next(0, limit / 5); i++) { n = new Customer(); n.BuyService(s); customers_income++; } period++; }