예제 #1
0
        private static void ProcessVectorOptions(TVector2D baseVect)
        {
            TVector2D tmpVect;
            double    tmpNum;
            bool      execute = true;

            do
            {
                Write(CHOOSE_OPTION);
                switch (ReadLine())
                {
                case "1":
                    WriteLine(baseVect.ToString());
                    break;

                case "2":
                    tmpVect = CreateVector2D();
                    WriteLine($"Vectors are {(baseVect != tmpVect ? "un" : "")}equal");
                    break;

                case "3":
                    WriteLine($"Vector length: baseVect.GetLength()");
                    break;

                case "4":
                    WriteLine($"Normalized vector: {baseVect.Normalize()}");
                    break;

                case "5":
                    tmpVect = CreateVector2D();
                    WriteLine(baseVect + tmpVect);
                    break;

                case "6":
                    tmpVect = CreateVector2D();
                    WriteLine(baseVect - tmpVect);
                    break;

                case "7":
                    tmpNum = GetDouble();
                    WriteLine(baseVect * tmpNum);
                    break;

                case "8":
                    tmpNum = GetDouble();
                    WriteLine(baseVect / tmpNum);
                    break;

                case "9":
                    baseVect = CreateVector2D();
                    break;

                default:
                    execute = false;
                    break;
                }
            } while (execute);
            WriteLine("Exited from 2d vector menu");
        }
예제 #2
0
        private static void Main(string[] _)
        {
            WriteLine("1. Create single dimension array");
            WriteLine("2. Create 2D vector");
            WriteLine("3. Create 3D vector");
            WriteLine(EXIT_OPTION);
            bool execute = true;

            do
            {
                Write(CHOOSE_OPTION);
                switch (ReadLine())
                {
                case "1":
                    var array = CreateDoubleArray();
                    PrintArrayOptions();
                    ProcessArrayOptions(array);
                    break;

                case "2":
                    TVector2D baseVect2D = CreateVector2D();
                    PrintVectorOptions();
                    ProcessVectorOptions(baseVect2D);
                    break;

                case "3":
                    TVector3D baseVect3D = CreateVector3D();
                    PrintVectorOptions();
                    ProcessVectorOptions(baseVect3D);
                    break;

                default:
                    execute = false;
                    break;
                }
            } while (execute);
        }
예제 #3
0
 public bool Equals(TVector2D v) => X == v.X && Y == v.Y;
예제 #4
0
 public TVector2D(TVector2D v1)
 {
     X = v1.X; Y = v1.Y;
 }