private void button1_Click(object sender, EventArgs e) { ObservationStruct[] Observations = new ObservationStruct[] { new ObservationStruct(0,23,15), new ObservationStruct(1,23,14), new ObservationStruct(2,23,14), new ObservationStruct(3,22,14), new ObservationStruct(8,20,14), new ObservationStruct(9,20,15), new ObservationStruct(10,19,14), new ObservationStruct(12,12,7), new ObservationStruct(18,11,7), new ObservationStruct(23,10,7), new ObservationStruct(29,10,6), }; LakeClass Lake = new LakeClass(Observations, "Lake Nepressing", 2.3, 35); textBoxName.Text = Lake.name; textBoxDepth.Text = System.String.Format("{0}", Lake.maxdepth); textBoxArea.Text = System.String.Format("{0}", Lake.area); textBoxEpi.Text = System.String.Format("{0} - {1}", 0, Lake.Array[LakeClass.privateThermocline(Lake)[0]].Depth); textBoxThermo.Text = System.String.Format("{0} - {1}", Lake.Array[LakeClass.privateThermocline(Lake)[0]].Depth, Lake.Array[LakeClass.privateThermocline(Lake)[1]].Depth); textBoxHypo.Text = System.String.Format("{0} - {1}", Lake.Array[LakeClass.privateThermocline(Lake)[1]].Depth, Lake.Array[Lake.Array.GetUpperBound(0)].Depth); textBoxAllowableO2.Text = LakeClass.AllowableO2string(Lake); textBoxMaxTemp.Text = System.String.Format("{0}",LakeClass.MaxTemp(Lake)); textBoxMinTemp.Text = System.String.Format("{0}",LakeClass.MinTemp(Lake)); richTextBox1.Text = System.String.Format("{0}", LakeClass.ObservationOutputString(Lake)); }
public static string AllowableO2string(LakeClass A) { string outputstring = ""; bool chooser = LakeClass.privateAllowableO2(A); if (chooser == true) { outputstring = "True"; } else if (chooser == false) { outputstring = "False"; } return outputstring; }
public static double MinTemp(LakeClass A) { double mintemp = 100; int counter = 0; while (counter <= A.Array.GetUpperBound(0)) { if (A.Array[counter].Temp < mintemp) { mintemp = A.Array[counter].Temp; } counter++; } return mintemp; }
public static double MaxTemp(LakeClass A) { double maxtemp = 0; int counter = 0; while (counter <= A.Array.GetUpperBound(0)) { if (A.Array[counter].Temp > maxtemp) { maxtemp = A.Array[counter].Temp; } counter++; }; return maxtemp; }
public static string ObservationOutputString(LakeClass A) { string outputstring =""; int i = 0; string lb1 = "Depth", lb2 = "Temp", lb3 = "O^2"; Console.WriteLine(""); Console.WriteLine("|{0,6}|{1,6}|{2,6}", lb1, lb2, lb3); outputstring += lb1 + lb2 + lb3 +"\n"; while (i < 21) { outputstring += "-"; i++; } outputstring += "\n"; i = 0; Console.WriteLine(""); while (i <= A.Array.GetUpperBound(0)) { outputstring += (A.Array[i]) + "\n"; i++; } return outputstring; }
public static bool privateAllowableO2(LakeClass A) { double mino2 = 5; bool allowableo2test = true;//dumee starting value if (LakeClass.privateO2levels(A)[1] >= mino2) { allowableo2test = true; } else if (LakeClass.privateO2levels(A)[1] < mino2) { allowableo2test = false; } return allowableo2test; }
private static double[] privateO2levels(LakeClass A) { int[] Tvals = LakeClass.privateThermocline(A); int counter; double o2sumEpi = 0, o2sumpHypo = 0, o2averageEpi = 0, o2averageHypo = 0; counter = 0; while (counter <= Tvals[0]) { o2sumEpi += A.Array[counter].Olevels; counter++; }; o2averageEpi = o2sumEpi / counter; counter = Tvals[1]; while (counter <= A.Array.GetUpperBound(0)) { o2sumpHypo += A.Array[counter].Olevels; counter++; }; o2averageHypo = o2sumpHypo / (A.Array.GetUpperBound(0) - Tvals[0]); double[] outputarray = new double[] { o2averageEpi, o2averageHypo }; return outputarray; }
public static int[] privateThermocline(LakeClass A) { double Slope, MaxSlope = 0; double deltaSlope = 0.2; //slope range. double ThermoD1 = 0, ThermoD2 = 0; //starting dummie values; int i = 0, j = i + 1; int tval1 = 0, tval2 = 0; while (j <= A.Array.GetUpperBound(0)) { Slope = Math.Abs((A.Array[j].Temp - A.Array[i].Temp) / (A.Array[j].Depth - A.Array[i].Depth)); if (Slope > MaxSlope) { MaxSlope = Slope; ThermoD1 = A.Array[i].Depth; tval1 = i; ThermoD2 = A.Array[j].Depth; tval2 = j; } else if ((Slope <= (MaxSlope + deltaSlope)) && (Slope >= (MaxSlope - deltaSlope))) { ThermoD2 = A.Array[j].Depth; } else { } i++; j++; } int[] Outputthermoarrayvalues = new int[] { tval1, tval2 }; return Outputthermoarrayvalues; }
private void button2_Click(object sender, EventArgs e) { ObservationStruct[] Observations = new ObservationStruct[] { new ObservationStruct(0,24,12), new ObservationStruct(0,24,12), new ObservationStruct(4,23,13), new ObservationStruct(6,20,10), new ObservationStruct(8,21,11), new ObservationStruct(10,17,9), new ObservationStruct(12,13,5), new ObservationStruct(14,13,4), new ObservationStruct(16,12,4), new ObservationStruct(18,12,4), new ObservationStruct(20,12,3), }; LakeClass Lake = new LakeClass(Observations, "LakeHadley", 1.7, 24); textBoxName.Text = Lake.name; textBoxDepth.Text = System.String.Format("{0}", Lake.maxdepth); textBoxArea.Text = System.String.Format("{0}", Lake.area); textBoxEpi.Text = System.String.Format("{0} - {1}", 0, Lake.Array[LakeClass.privateThermocline(Lake)[0]].Depth); textBoxThermo.Text = System.String.Format("{0} - {1}", Lake.Array[LakeClass.privateThermocline(Lake)[0]].Depth, Lake.Array[LakeClass.privateThermocline(Lake)[1]].Depth); textBoxHypo.Text = System.String.Format("{0} - {1}", Lake.Array[LakeClass.privateThermocline(Lake)[1]].Depth, Lake.Array[Lake.Array.GetUpperBound(0)].Depth); textBoxAllowableO2.Text = LakeClass.AllowableO2string(Lake); textBoxMaxTemp.Text = System.String.Format("{0}", LakeClass.MaxTemp(Lake)); textBoxMinTemp.Text = System.String.Format("{0}", LakeClass.MinTemp(Lake)); richTextBox1.Text = System.String.Format("{0}", LakeClass.ObservationOutputString(Lake)); }
private void button4_Click(object sender, EventArgs e) { ObservationStruct[] Observations = new ObservationStruct[] { new ObservationStruct(0,26,11), new ObservationStruct(1,25,11), new ObservationStruct(2,24,11), new ObservationStruct(4,24,10), new ObservationStruct(5,23,11), new ObservationStruct(8,20,10), new ObservationStruct(9,17,9), new ObservationStruct(11,17,9), new ObservationStruct(13,17,10), }; LakeClass Lake = new LakeClass(Observations, "Ortonville Lake", 1.3, 15); textBoxName.Text = Lake.name; textBoxDepth.Text = System.String.Format("{0}", Lake.maxdepth); textBoxArea.Text = System.String.Format("{0}", Lake.area); textBoxEpi.Text = System.String.Format("{0} - {1}", 0, Lake.Array[LakeClass.privateThermocline(Lake)[0]].Depth); textBoxThermo.Text = System.String.Format("{0} - {1}", Lake.Array[LakeClass.privateThermocline(Lake)[0]].Depth, Lake.Array[LakeClass.privateThermocline(Lake)[1]].Depth); textBoxHypo.Text = System.String.Format("{0} - {1}", Lake.Array[LakeClass.privateThermocline(Lake)[1]].Depth, Lake.Array[Lake.Array.GetUpperBound(0)].Depth); textBoxAllowableO2.Text = LakeClass.AllowableO2string(Lake); textBoxMaxTemp.Text = System.String.Format("{0}", LakeClass.MaxTemp(Lake)); textBoxMinTemp.Text = System.String.Format("{0}", LakeClass.MinTemp(Lake)); richTextBox1.Text = System.String.Format("{0}", LakeClass.ObservationOutputString(Lake)); }
private void button3_Click(object sender, EventArgs e) { ObservationStruct[] Observations = new ObservationStruct[] { new ObservationStruct(0,23,8), new ObservationStruct(3,24,8), new ObservationStruct(5,22,7), new ObservationStruct(8,15,4), new ObservationStruct(10,16,3), new ObservationStruct(13,15,3), new ObservationStruct(15,14,2), }; LakeClass Lake = new LakeClass(Observations, "Fish Lake", 1.1, 19); textBoxName.Text = Lake.name; textBoxDepth.Text = System.String.Format("{0}", Lake.maxdepth); textBoxArea.Text = System.String.Format("{0}", Lake.area); textBoxEpi.Text = System.String.Format("{0} - {1}", 0, Lake.Array[LakeClass.privateThermocline(Lake)[0]].Depth); textBoxThermo.Text = System.String.Format("{0} - {1}", Lake.Array[LakeClass.privateThermocline(Lake)[0]].Depth, Lake.Array[LakeClass.privateThermocline(Lake)[1]].Depth); textBoxHypo.Text = System.String.Format("{0} - {1}", Lake.Array[LakeClass.privateThermocline(Lake)[1]].Depth, Lake.Array[Lake.Array.GetUpperBound(0)].Depth); textBoxAllowableO2.Text = LakeClass.AllowableO2string(Lake); textBoxMaxTemp.Text = System.String.Format("{0}", LakeClass.MaxTemp(Lake)); textBoxMinTemp.Text = System.String.Format("{0}", LakeClass.MinTemp(Lake)); richTextBox1.Text = System.String.Format("{0}", LakeClass.ObservationOutputString(Lake)); }