static void Main(string[] args) { //Point3D tests Point3D pointOne = new Point3D(2, 3, 5); Point3D pointTwo = new Point3D(-1, -4, 0); Console.WriteLine("--------\nPoint3D tests:\n--------"); Console.WriteLine("Point 1 coordinates: " + pointOne.ToString()); Console.WriteLine("Point 2 coordinates: " + pointTwo.ToString()); Console.WriteLine("Distance between points: " + Calculation.PointsDistance(pointOne, pointTwo)); //Path tests string textFileOne = @"../../textfiles/fileOne.txt"; string textFileTwo = @"../../textfiles/fileTwo.txt"; //изтрий всичко във fileTwo.txt и го провери след стартиране на програмата, за да видиш, че копира всичко от fileOne.txt PathStorage.ReadFromFile(textFileOne); PathStorage.WriteOnFile(textFileTwo, Path.ReturnPoints()); //Generic tests GenericList <int> list = new GenericList <int>(); for (int i = 0; i < 32; i++) { list.Add(i); } Console.WriteLine("--------\nGeneric tests:\n--------"); Console.WriteLine("List ToString: \n" + list.ToString() + "\n"); Console.WriteLine("Access pos 27 " + list.Access(27)); list.Remove(27); Console.WriteLine("Position 27 after Remove: " + list.Access(27)); list.Insert(1337, 28); Console.WriteLine("position 28: " + list.Access(28)); Console.WriteLine("1337 found at pos: " + list.Find(1337)); Console.WriteLine("Min: " + list.Min()); Console.WriteLine("Max: " + list.Max()); list.Clear(); Console.WriteLine("\nList ToString after Clear: \n" + list.ToString() + "\n"); Matrix <int> matrixOne = new Matrix <int>(4, 5); Matrix <int> matrixTwo = new Matrix <int>(4, 5); Matrix <int> resultmatrix = new Matrix <int>(4, 5); //Matrix<int> matrixOne = new Matrix<int>(4, 5); //Matrix<int> matrixTwo = new Matrix<int>(3, 5); това е за проба на Exception-а, когато матриците са с различен размер resultmatrix = matrixOne + matrixTwo; resultmatrix = matrixOne - matrixTwo; resultmatrix = matrixOne * matrixTwo; //не ми остана време за тест на Версията. }
static void Main(string[] args) { Point3D myPoint = new Point3D(35, 14, 3); Point3D secondPoint = new Point3D(17, 6, 2); // var x = DistanceBetweenPoints.CalculateDistance(myPoint, secondPoint); // Path c = new Path(); // c.AddToPath(secondPoint); // c.AddToPath(myPoint); // PathStorage.SaveToFile(c); // PathStorage.LoadFromFile(c); GenericList <Point3D> genList = new GenericList <Point3D>(3); genList.AddElement(myPoint); genList.AddElement(secondPoint); var nas = genList.Min <Point3D>(myPoint, secondPoint); // var x2 = genList.FindElement(new Point3D {X=32,Y=144,Z=92 }); Console.WriteLine("++++++++++++++++"); //Console.WriteLine(x2); Console.WriteLine("++++++++++++++++"); //genList.RemovingElement(0); //genList.InsertElement(1, "naskooo"); //genList.RemoveElement(0); // genList.InsertToList(2, "Monster"); // // genList.AddElement("ddd"); // genList.RemoveElement(1); // genList.RemoveElement(3); // genList.RemoveElement(2); // genList.InsertToList(3, "doncho"); // genList.AddElement("nasssssss"); Console.WriteLine("====================="); foreach (var item in genList.elementContainer) { Console.WriteLine(item); } }
static void Main() { var point1 = new Point3D(1, 2, 3); var point2 = new Point3D(5, 2, 7); //Problem 1. Structure Console.WriteLine("Problem 1. Structure:"); Console.WriteLine(point1); Console.WriteLine(point2); Console.WriteLine(); //Problem 2. Static read-only field Console.WriteLine("Problem 2. Static read-only field:"); Console.WriteLine(Point3D.O); Console.WriteLine(); //Problem 3. Static class Console.WriteLine(CalcDistanceIn3D.CalcDistance(point1, point2)); //Problem 4. Path var newPath = new Path(); newPath.AddPointToList(point1); newPath.AddPointToList(point2); newPath.AddPointToList(point1); newPath.AddPointToList(point1); //Problem 5. Generic class PathStorage.LoadFile(); PathStorage.SaveFile(newPath); // Declare a list of type int GenericList <int> intList = new GenericList <int>(4); // Declare a list of type string GenericList <string> stringList = new GenericList <string>(7); intList.Add(-28); intList.Add(7); intList.Add(11); Console.Write("Problem 5: List count: "); Console.WriteLine(intList.Count); Console.Write("Problem 5: Element at index 1: "); Console.WriteLine(intList.ElementAtIndex(1)); Console.Write("Problem 5: Remove the element at index 1: "); intList.Remove(1); Console.WriteLine(intList.ElementAtIndex(1)); Console.Write("Problem 5: Insert element 12 at index 1: "); intList.InsertAt(12, 1); Console.WriteLine(intList.ElementAtIndex(1)); Console.Write("Problem 5: The position of element 12 is with index: "); Console.WriteLine(intList.IndexOf(12)); Console.Write("Problem 5: Printing the entire list: "); Console.WriteLine(intList.ToString()); //Problem 6. Auto-grow for (int i = 0; i < 40; i += 2) { intList.Add(i); } Console.WriteLine("Problem 6: Adding new elements to the list and expanding its size: "); Console.WriteLine(intList.ToString()); //Problem 7. Min and Max Console.WriteLine("Problem 7: "); Console.Write("Thi minimal value in the entire list is: "); Console.WriteLine(intList.Min()); Console.Write("Thi maximal value in the entire list is: "); Console.WriteLine(intList.Max()); Console.WriteLine(); //Problem 8. Matrix Console.WriteLine("Problem 8. Matrix:"); Matrix <int> testMatrix = new Matrix <int>(7, 9); testMatrix[3, 5] = 17; testMatrix[4, 5] = 60; var indexAtPoint = testMatrix[3, 5]; Console.WriteLine(@"Value at index [3, 5] is: {0}", indexAtPoint); //this class is for testing Matrix <int> testMatrixFirst = new Matrix <int>(4, 4); Matrix <int> testMatrixSecond = new Matrix <int>(4, 4); //fill the first matrix for (int i = 0; i < testMatrixFirst.Rows; i++) { for (int j = 0; j < testMatrixFirst.Cols; j++) { testMatrixFirst[i, j] = i + j + 1; } } //fill the second matrix for (int i = 0; i < testMatrixSecond.Rows; i++) { for (int j = 0; j < testMatrixSecond.Cols; j++) { testMatrixSecond[i, j] = i * j; } } //Operations with matrix Matrix <int> addingMatrix = testMatrixFirst + testMatrixSecond; Matrix <int> substractMatrix = testMatrixFirst - testMatrixSecond; Matrix <int> multiMatrix = testMatrixFirst * testMatrixSecond; //Printing the result of adding: Console.WriteLine("The result from adding two matrix: "); addingMatrix.PrintMatrix(); Console.WriteLine(); //Printing the result of substracting: Console.WriteLine("The result from substracting two matrix: "); substractMatrix.PrintMatrix(); Console.WriteLine(); //Printing the result of multiplication: Console.WriteLine("The result from multiplication of two matrix: "); multiMatrix.PrintMatrix(); Console.WriteLine(); //Implement the true operator Console.WriteLine("Implement the true operator: "); if (testMatrixFirst) { Console.WriteLine("Does not have zero element"); } else { Console.WriteLine("Has zero element"); } }
static void Main(string[] args) { GenericList <int> newList = new GenericList <int>(3); Console.WriteLine("Capacity before adding an elements: "); Console.WriteLine(newList.Capacity); newList.Add(1); newList.Add(2); newList.Add(3); newList.Add(4); newList.Add(5); newList.Add(6); newList.Add(7); Console.WriteLine("The list after Adding elements from 1 to 7:"); Console.WriteLine(newList); Console.WriteLine("Capacity after adding an elements: "); Console.WriteLine(newList.Capacity); newList.Insert(7, 8); newList.Insert(8, 9); newList.Insert(9, 10); newList.Insert(10, 11); newList.Insert(11, 12); Console.WriteLine("The list after Insert elements from 8 to 12 at positions from 7 to 11:"); Console.WriteLine(newList); newList.RemoveAt(2); newList.RemoveAt(4); Console.WriteLine("The list after Remove elements in positions 2 and 4:"); Console.WriteLine(newList); Console.WriteLine("The min element of the list is:"); Console.WriteLine(newList.Min()); Console.WriteLine("The max element of the list is:"); Console.WriteLine(newList.Max()); Console.WriteLine("The list after clear method:"); newList.Clear(); Console.WriteLine(newList); Console.WriteLine(); Matrix <int> matrix1 = new Matrix <int>(3, 3); matrix1[0, 0] = 1; matrix1[0, 1] = 2; matrix1[0, 2] = 3; matrix1[1, 0] = 4; matrix1[1, 1] = 5; matrix1[1, 2] = 0; matrix1[2, 0] = 7; matrix1[2, 1] = 8; matrix1[2, 2] = 9; Matrix <int> matrix2 = new Matrix <int>(3, 3); matrix2[0, 0] = 1; matrix2[0, 1] = 2; matrix2[0, 2] = 3; matrix2[1, 0] = 4; matrix2[1, 1] = 5; matrix2[1, 2] = 6; matrix2[2, 0] = 7; matrix2[2, 1] = 8; matrix2[2, 2] = 9; Console.WriteLine("The sum of the matrix \n{0} \nand matrix \n{1} \nis:", matrix1, matrix2); Console.WriteLine(matrix1 + matrix2); Console.WriteLine("The division of the matrix \n{0} \nand matrix \n{1} \nis:", matrix1, matrix2); Console.WriteLine(matrix1 - matrix2); Console.WriteLine("The Product of the matrix \n{0} \nand matrix \n{1} \nis:", matrix1, matrix2); Console.WriteLine(matrix1 * matrix2); Console.WriteLine("Operator True for the matrix:"); if (matrix1) { Console.WriteLine("The matrix: \n{0} \n has NO ZERO elements!", matrix1); } else { Console.WriteLine("The matrix:\n{0} \n HAS ZERO elements!", matrix1); } if (matrix2) { Console.WriteLine("The matrix:\n{0} \n has NO ZERO elements!", matrix2); } else { Console.WriteLine("The matrix: \n{0} \n HAS ZERO elements!", matrix2); } }