public virtual string ReadDataByLine()
 {
     EmpiricalTestingConsole.Write(new string[1] {
         "public virtual string ReadDataByLine()"
     });
     return(Console.ReadLine());
 }
 public QuadraticEquation(Coefficients coefficients)
 {
     EmpiricalTestingConsole.Write(new string[1] {
         "public QuadraticEquation (Coefficients coefficients)"
     });
     EmpiricalTestingConsole.Write(new string[1] {
         "coefficients=" + coefficients.ToString()
     });
     EmpiricalTestingConsole.Write(new string[3] {
         "A=" + coefficients.A, "B=" + coefficients.B, "C=" + coefficients.C
     });
     if (coefficients != null)
     {
         EmpiricalTestingConsole.Write(new string[1] {
             "if (coefficients != null)"
         });
         Coefficients = coefficients;
         EmpiricalTestingConsole.Write(new string[1] {
             "Coefficients = coefficients"
         });
         EmpiricalTestingConsole.Write(new string[1] {
             "Coefficients=" + Coefficients.ToString()
         });
         EmpiricalTestingConsole.Write(new string[3] {
             "A=" + Coefficients.A, "B=" + Coefficients.B, "C=" + Coefficients.C
         });
     }
     else
     {
         EmpiricalTestingConsole.Write(new string[1] {
             "else"
         });
         throw new Exception("'coefficients' cannot be null");
     }
 }
예제 #3
0
 public OutputProcessing(Output output)
 {
     EmpiricalTestingConsole.Write(new string[1] {
         "public OutputProcessing(Output output)"
     });
     _output = output;
     EmpiricalTestingConsole.Write(new string[1] {
         "_output = output"
     });
     EmpiricalTestingConsole.Write(new string[1] {
         "_output=" + output.ToString()
     });
 }
예제 #4
0
 static void Main(string[] args)
 {
     EmpiricalTestingConsole.Write(new string[1] {
         "static void Main(string[] args)"
     });
     try
     {
         EmpiricalTestingConsole.Write(new string[1] {
             "try"
         });
         InputProcessing inputProcessing = new InputProcessing(new Input(), new Output());
         EmpiricalTestingConsole.Write(new string[1] {
             "InputProcessing inputProcessing = new InputProcessing(new Input(), new Output())"
         });
         EmpiricalTestingConsole.Write(new string[1] {
             "inputProcessing=" + inputProcessing.ToString()
         });
         OutputProcessing outputProcessing = new OutputProcessing(new Output());
         EmpiricalTestingConsole.Write(new string[1] {
             "OutputProcessing outputProcessing = new OutputProcessing(new Output())"
         });
         EmpiricalTestingConsole.Write(new string[1] {
             "outputProcessing=" + outputProcessing.ToString()
         });
         QuadraticEquation quadraticEquation = new QuadraticEquation(inputProcessing.GetData());
         EmpiricalTestingConsole.Write(new string[1] {
             "QuadraticEquation quadraticEquation = new QuadraticEquation(inputProcessing.GetData())"
         });
         EmpiricalTestingConsole.Write(new string[1] {
             "quadraticEquation=" + quadraticEquation.ToString()
         });
         outputProcessing.PutData(quadraticEquation.SolveWithRealSolutions());
         EmpiricalTestingConsole.Write(new string[1] {
             "outputProcessing.PutData(quadraticEquation.SolveWithRealSolutions())"
         });
     }
     catch (Exception e)
     {
         EmpiricalTestingConsole.Write(new string[1] {
             "catch (Exception e)"
         });
         Console.WriteLine(e.Message);
         EmpiricalTestingConsole.Write(new string[1] {
             "Console.WriteLine(e.Message)"
         });
     }
 }
예제 #5
0
        public void PutData(Solution solution)
        {
            EmpiricalTestingConsole.Write(new string[1] {
                "public void PutData(Solution solution)"
            });
            EmpiricalTestingConsole.Write(new string[1] {
                "solution=" + solution.ToString()
            });
            EmpiricalTestingConsole.Write(new string[2] {
                "solution.Root1=" + solution.Root1.ToString(), "solution.Root2=" + solution.Root2.ToString()
            });
            string line1, line2;

            EmpiricalTestingConsole.Write(new string[1] {
                "string line1, line2"
            });
            string[] newSolution = Decimals.Round(solution, 2);
            EmpiricalTestingConsole.Write(new string[1] {
                "string[] newSolution = Decimals.Round(solution, 2)"
            });
            EmpiricalTestingConsole.Write(new string[2] {
                "newSolution[0]=" + newSolution[0], "newSolution[1]=" + newSolution[1]
            });
            line1 = "x1=" + newSolution[0];
            EmpiricalTestingConsole.Write(new string[1] {
                "line1 = " + "x1 = " + " + newSolution[0]"
            });
            EmpiricalTestingConsole.Write(new string[1] {
                "line1=" + line1
            });
            line2 = "x2=" + newSolution[1];
            EmpiricalTestingConsole.Write(new string[1] {
                "line2 = " + "x2 = " + " + newSolution[1]"
            });
            EmpiricalTestingConsole.Write(new string[1] {
                "line2=" + line2
            });
            _output.WriteData(new string[2] {
                line1, line2
            });
            EmpiricalTestingConsole.Write(new string[1] {
                "_output.WriteData(new string[2] {line1, line2})"
            });
        }
예제 #6
0
 public Coefficients(int coefficientA, int coefficientB, int coefficientC)
 {
     EmpiricalTestingConsole.Write(new string[1] {
         "public Coefficients(int coefficientA, int coefficientB, int coefficientC)"
     });
     EmpiricalTestingConsole.Write(new string[1] {
         "coefficientA=" + coefficientA.ToString()
     });
     EmpiricalTestingConsole.Write(new string[1] {
         "coefficientB=" + coefficientB.ToString()
     });
     EmpiricalTestingConsole.Write(new string[1] {
         "coefficientB=" + coefficientB.ToString()
     });
     if (coefficientA == 0)
     {
         EmpiricalTestingConsole.Write(new string[1] {
             "if (coefficientA == 0)"
         });
         throw new Exception("The 'a' coefficient cannot equal 0");
     }
     A = coefficientA;
     EmpiricalTestingConsole.Write(new string[1] {
         "A = coefficientA"
     });
     EmpiricalTestingConsole.Write(new string[1] {
         "A=" + A.ToString()
     });
     B = coefficientB;
     EmpiricalTestingConsole.Write(new string[1] {
         "B = coefficientB"
     });
     EmpiricalTestingConsole.Write(new string[1] {
         "B=" + B.ToString()
     });
     C = coefficientC;
     EmpiricalTestingConsole.Write(new string[1] {
         "C = coefficientC"
     });
     EmpiricalTestingConsole.Write(new string[1] {
         "C=" + C.ToString()
     });
 }
예제 #7
0
 public Solution(double root1, double root2)
 {
     EmpiricalTestingConsole.Write(new string[1] {
         "public Solution(double root1, double root2)"
     });
     EmpiricalTestingConsole.Write(new string[2] {
         "root1=" + root1.ToString(), "root2=" + root2.ToString()
     });
     Root1 = root1;
     EmpiricalTestingConsole.Write(new string[1] {
         "Root1 = root1"
     });
     EmpiricalTestingConsole.Write(new string[1] {
         "Root1=" + Root1.ToString()
     });
     Root2 = root2;
     EmpiricalTestingConsole.Write(new string[1] {
         "Root2 = root2"
     });
     EmpiricalTestingConsole.Write(new string[1] {
         "Root2=" + Root2.ToString()
     });
 }
 public static string[] Round(Solution solution, int numberDecimals)
 {
     EmpiricalTestingConsole.Write(new string[1] {
         "public static string[] Round(Solution solution, int numberDecimals)"
     });
     EmpiricalTestingConsole.Write(new string[1] {
         "solution=" + solution.ToString()
     });
     EmpiricalTestingConsole.Write(new string[2] {
         "solution.Root1=" + solution.Root1.ToString(), "solution.Root2=" + solution.Root2.ToString()
     });
     EmpiricalTestingConsole.Write(new string[1] {
         "numberDecimals=" + numberDecimals.ToString()
     });
     string[] roots;
     EmpiricalTestingConsole.Write(new string[1] {
         "string[] roots"
     });
     roots = new string[2]
     {
         (Math.Truncate(Math.Pow(10, numberDecimals) * solution.Root1) / (double)Math.Pow(10, numberDecimals)).ToString(),
         (Math.Truncate(Math.Pow(10, numberDecimals) * solution.Root2) / (double)Math.Pow(10, numberDecimals)).ToString(),
     };
     EmpiricalTestingConsole.Write(new string[5]
     {
         "roots = new string[2]",
         "{",
         "(Math.Truncate(Math.Pow(10,numberDecimals) * solution.Root1) / (double) Math.Pow(10,numberDecimals)).ToString(),",
         "(Math.Truncate(Math.Pow(10,numberDecimals) * solution.Root2) / (double) Math.Pow(10,numberDecimals)).ToString(),",
         "};"
     });
     EmpiricalTestingConsole.Write(new string[2] {
         "roots[0]=" + roots[0], "roots[1]=" + roots[1]
     });
     return(roots);
 }
        public Solution SolveWithRealSolutions()
        {
            EmpiricalTestingConsole.Write(new string[1] {
                "public Solution SolveWithRealSolutions()"
            });
            Solution solution = null;

            EmpiricalTestingConsole.Write(new string[1] {
                "Solution solution = null"
            });
            if (Delta.Equals(0))
            {
                EmpiricalTestingConsole.Write(new string[1] {
                    "if (Delta.Equals(0))"
                });
                solution = new Solution(
                    (double)(-Coefficients.B) / (double)(2 * Coefficients.A),
                    (double)(-Coefficients.B) / (double)(2 * Coefficients.A)
                    );
                EmpiricalTestingConsole.Write(new string[4]
                {
                    "solution = new Solution(",
                    "(double)(-Coefficients.B) / (double)(2 * Coefficients.A),",
                    "(double)(-Coefficients.B) / (double)(2 * Coefficients.A)",
                    ")"
                });
                EmpiricalTestingConsole.Write(new string[1] {
                    "solution=" + solution.ToString()
                });
                EmpiricalTestingConsole.Write(new string[2] {
                    "solution.Root1=" + solution.Root1.ToString(), "solution.Root2=" + solution.Root2.ToString()
                });
            }
            if (Delta > 0)
            {
                EmpiricalTestingConsole.Write(new string[1] {
                    " if(Delta > 0)"
                });
                solution = new Solution(
                    (double)(-Coefficients.B + Math.Sqrt(Delta)) / (double)(2 * Coefficients.A),
                    (double)(-Coefficients.B - Math.Sqrt(Delta)) / (double)(2 * Coefficients.A)
                    );
                EmpiricalTestingConsole.Write(new string[4]
                {
                    "solution = new Solution(",
                    "(double)(-Coefficients.B + Math.Sqrt(Delta)) / (double)(2 * Coefficients.A),",
                    "(double)(-Coefficients.B - Math.Sqrt(Delta)) / (double)(2 * Coefficients.A)",
                    ")"
                });
                EmpiricalTestingConsole.Write(new string[1] {
                    "solution=" + solution.ToString()
                });
                EmpiricalTestingConsole.Write(new string[2] {
                    "solution.Root1=" + solution.Root1.ToString(), "solution.Root2=" + solution.Root2.ToString()
                });
            }
            if (Delta < 0)
            {
                EmpiricalTestingConsole.Write(new string[1] {
                    " if (Delta < 0)"
                });
                throw new Exception("the equation do not have a real solution");
            }
            return(solution);
        }