示例#1
0
        public void FindKAndB(double x1, double y1, double x2, double y2, double expectedK, double expectedB)
        {
            double actualK = VariablesMath.SolveIndexK(x1, y1, x2, y2);
            double actualB = VariablesMath.SolveIndexB(x1, y1, x2, y2);

            Assert.AreEqual(expectedK, actualK);
            Assert.AreEqual(expectedB, actualB);
        }
示例#2
0
 public void FindKAndBNegative(double x1, double y1, double x2, double y2)
 {
     try
     {
         VariablesMath.SolveIndexK(x1, y1, x2, y2);
         VariablesMath.SolveIndexB(x1, y1, x2, y2);
     }
     catch
     {
         Assert.Pass();
     }
     Assert.Fail();
 }
示例#3
0
        static void Main(string[] args)
        {
            double x1, y1, x2, y2;

            Console.WriteLine("Enter x1:");
            x1 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter y1:");
            y1 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter x2:");
            x2 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter y2:");
            y2 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("A (" + x1 + "," + y1 + ")");
            Console.WriteLine("B (" + x2 + "," + y2 + ")");
            double k = VariablesMath.SolveIndexK(x1, y1, x2, y2);
            double b = VariablesMath.SolveIndexB(x1, y1, x2, y2);

            Console.Write("Stright line equation: y=");
            Console.Write(k + "*x + " + b);
        }