Example #1
0
        private void do5()
        {
            Ship currentShip;

            DataTable table = new DataTable();
            double[][] data = new double[6][];

            for (int countOfColumns = 0; countOfColumns < 6; countOfColumns++)
            {
                double power = Math.Pow(4,countOfColumns+1);
                double mass = 50 * power;

                table.Columns.Add(new DataColumn(string.Format("Mass: {0}", mass ),typeof(string)));
                data[countOfColumns] = new double[100];
            }

            for (int countOfEngines = 0; countOfEngines < 100; countOfEngines++)
            {
                DataRow row = table.NewRow();
                for (int countOfMass = 0; countOfMass < 6; countOfMass++)
                {
                    double scale = Convert.ToDouble(tbxScale.Text);
                    currentShip = new Ship(countOfEngines, 50 * Math.Pow(4,countOfMass+1),scale);
                    row[countOfMass] = "Eng: " + countOfEngines.ToString() + " MP: " + currentShip.GetMP() + " Mass: " + currentShip.TotalMass.ToString()+":"+ Math.Log((currentShip.TotalMass/50),4);;
                    data[countOfMass][countOfEngines] = currentShip.GetMP();
                }
                table.Rows.Add(row);

            }
            dgvResults.DataSource = table;

            //chart
            chart1.Series.Clear();

            for (int i = 0; i < 6; i++)
            {
                Series series = chart1.Series.Add(string.Format("Mass: {0}",50*Math.Pow(4,i+1)));
                series.BorderWidth = 3;
                series.ChartType = SeriesChartType.SplineArea;
                for (int j = 0; j < 100; j++)
                {
                    series.Points.AddXY(j, data[i][j]);
                }
            }
        }
Example #2
0
        private void do6()
        {
            Ship currentShip;

            DataTable table = new DataTable();
            double[][] data = new double[6][];

            for (int countOfColumns = 0; countOfColumns < 6; countOfColumns++)
            {
                table.Columns.Add(new DataColumn(string.Format("scale: {0}", countOfColumns+2), typeof(string)));
                data[countOfColumns] = new double[100];
            }

            for (int countOfEngines = 0; countOfEngines < 100; countOfEngines++)
            {
                DataRow row = table.NewRow();
                for (int scale = 0; scale < 6; scale++)
                {
                    currentShip = new Ship(countOfEngines, Convert.ToDouble(tbxMass.Text),scale+2);
                    row[scale] = "Eng: "+ countOfEngines.ToString() + " MP: " + currentShip.GetMP()+" Mass: "+currentShip.TotalMass.ToString();
                    data[scale][countOfEngines] = currentShip.GetMP();
                }
                table.Rows.Add(row);

            }
            dgvResults.DataSource = table;

            //chart
            chart1.Series.Clear();

            for (int i = 0; i < 6; i++)
            {
                Series series = chart1.Series.Add(string.Format("Scale: {0}", i+2));
                series.BorderWidth = 3;
                series.ChartType = SeriesChartType.SplineArea;
                for (int j = 0; j < 100; j++)
                {
                    series.Points.AddXY(j, data[i][j]);
                }
            }
        }