public void TestCalculateAvarageOfSymbols() { Lab1 lab1Instance = new Lab1(); int result = lab1Instance.CalculateAvarageOfSymbols(mockInput); Assert.AreEqual(result, 20); }
public void TestGetStringMethodShouldReturnString() { Lab1 lab1Instance = new Lab1(); string[] result = lab1Instance.getStringsLengthLessThen(20, mockInput); Assert.AreEqual(result, mockOutput); }
public UCLab1() { Dock = DockStyle.Fill; _lab1 = new Lab1(); InitializeComponent(); }
static void Main(string[] args) { Lab1 lab1 = new Lab1(); lab1.Start(); Console.ReadKey(); }
static void ExecuteLab1() { var lab1 = new Lab1(); var array = new[] { 1, 2, 3, 4, 5, 6, 7, 8 }; var result = lab1.PureSum(array); Console.WriteLine(result); // 36 }
private void ProceedResult() { var rle = Lab1.RLE(_bytes); lblRLE.Text = Utils.GetCompressPercentage(_bytes, rle); var lz77 = Lab1.LZ77(_bytes); //lblLZ77.Text = Utils.GetCompressPercentage(_bytes, lz77); var hc = Lab1.HuffmanCode(_bytes); //lblHC.Text = Utils.GetCompressPercentage(_bytes, hc); }
public void CountExceptions_InitCounters_Zero() { // arrange var lab1 = new Lab1(); // act: nothing // assert Assert.AreEqual(lab1.CounterCriticalExceptions, 0); Assert.AreEqual(lab1.CounterNotCriticalExceptions, 0); }
public void WhereTest() { Lab1 testClass = new Lab1(); IEnumerable <int> resultFibonacciNumbers = testClass.FibonacciSequence(10); IEnumerable <int> resultFibonacciEvenNumbers = resultFibonacciNumbers.Where(fibonacciNumber => fibonacciNumber % 2 == 0); int[] evenFibonacciExpectedNumbers = { 0, 2, 8, 34 }; CollectionAssert.AreEqual(resultFibonacciEvenNumbers.ToArray(), evenFibonacciExpectedNumbers); }
public void EveryOtherTest() { string[] originalList = { "red", "green", "blue", "cyan", "magenta", "yellow", "black" }; string[] evenExpected = { "red", "blue", "magenta", "black" }; string[] oddExpected = { "green", "cyan", "yellow" }; int[] originalListNumbers = { 0, 1, 2, 3, 4, 5 }; int[] evenExpectedNumbers = { 0, 2, 4 }; int[] oddExpectedNumbers = { 1, 3, 5 }; Lab1 testClass = new Lab1(); IEnumerable <int> resultFibonacciNumbers = testClass.FibonacciSequence(10); int[] evenFibonacciExpectedNumbers = { 0, 1, 3, 8, 21 }; int[] oddFibonacciExpectedNumbers = { 1, 2, 5, 13, 34 }; IEnumerable <string> resultEven = originalList.EveryOther(true); IEnumerable <string> resultOdd = originalList.EveryOther(false); IEnumerable <int> resultEvenNumbers = originalListNumbers.EveryOther(true); IEnumerable <int> resultOddNumbers = originalListNumbers.EveryOther(false); IEnumerable <int> resultFibonacciEvenNumbers = resultFibonacciNumbers.EveryOther(true); IEnumerable <int> resultFibonacciOddNumbers = resultFibonacciNumbers.EveryOther(false); CollectionAssert.AreEqual(resultEven.ToArray(), evenExpected); CollectionAssert.AreEqual(resultOdd.ToArray(), oddExpected); CollectionAssert.AreEqual(resultEvenNumbers.ToArray(), evenExpectedNumbers); CollectionAssert.AreEqual(resultOddNumbers.ToArray(), oddExpectedNumbers); CollectionAssert.AreEqual(resultEvenNumbers.ToArray(), evenExpectedNumbers); CollectionAssert.AreEqual(resultOddNumbers.ToArray(), oddExpectedNumbers); CollectionAssert.AreEqual(resultFibonacciEvenNumbers.ToArray(), evenFibonacciExpectedNumbers); CollectionAssert.AreEqual(resultFibonacciOddNumbers.ToArray(), oddFibonacciExpectedNumbers); }
private static async Task RunAsync(CancellationToken cancellationToken) { try { var lab = new Lab1(); await lab.RunAsync(cancellationToken); } catch (Exception exp) { Trace.TraceError(exp.ToString()); throw; } }
public void HelloWorldTest() { string expectedString = "Hello from Lab1!"; Lab1 testClass = new Lab1(); string testString; testString = testClass.HelloWorld(); Console.Write(testString); Assert.AreEqual(expectedString, testString); }
static void Main(string[] args) { int processes = 6; Lab1 task = new Lab1(processes); task.ResetTable(processes); // Shortest Remaining Time First Algorithm task.SRTF(); task.Output(); // Round Robin Algorithm task.RR(); task.Output(); }
public void FibonacciSequenceTest() { int[] expected = new int[] { 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 }; Lab1 testClass = new Lab1(); IEnumerable <int> result = testClass.FibonacciSequence(10); foreach (int number in result) { Console.WriteLine(number); } // Assert.AreEqual(expected, result.ToArray()); CollectionAssert.AreEqual(expected, result.ToArray()); }
static void Main(string[] args) { //Lab1 Console.WriteLine("LAB 1"); Lab1.RunLab1(); Console.WriteLine("-------------------------------------------------\n"); //Lab2 Console.WriteLine("LAB 2"); Lab2.RunLab2(); Console.WriteLine("-------------------------------------------------\n"); //Lab3 Console.WriteLine("LAB 3"); Lab3.RunLab3(); Console.WriteLine("-------------------------------------------------\n"); }
public void GroupByTest() { Lab1 testClass = new Lab1(); IEnumerable <int> resultFibonacciNumbers = testClass.FibonacciSequence(10); IEnumerable <IGrouping <string, int> > resultFibonacciEvenAndOddNumbers = resultFibonacciNumbers.GroupBy(fibonacciNumber => fibonacciNumber % 2 == 0 ? "Even" : "Odd"); int[] evenFibonacciExpectedNumbers = { 0, 2, 8, 34 }; int[] oddFibonacciExpectedNumbers = { 1, 1, 3, 5, 13, 21 }; int[] evenFibonacciResultNumbers = resultFibonacciEvenAndOddNumbers.ToArray()[0].ToArray(); int[] oddFibonacciResultNumbers = resultFibonacciEvenAndOddNumbers.ToArray()[1].ToArray(); CollectionAssert.AreEqual(evenFibonacciResultNumbers.ToArray(), evenFibonacciExpectedNumbers); CollectionAssert.AreEqual(oddFibonacciResultNumbers.ToArray(), oddFibonacciExpectedNumbers); }
public void CountExceptions_CounterValues_Correct() { // arrange var criticalExceptions = new List <Type>() { typeof(DivideByZeroException), typeof(OutOfMemoryException), typeof(StackOverflowException), typeof(InsufficientMemoryException), typeof(InsufficientExecutionStackException) }; var nonCriticalExceptions = new List <Type>() { typeof(ArgumentNullException), typeof(ArgumentOutOfRangeException), typeof(NullReferenceException), typeof(AccessViolationException), typeof(IndexOutOfRangeException), typeof(InvalidOperationException) }; var lab1 = new Lab1(); // act foreach (var item in criticalExceptions) { var instance = (Exception)Activator.CreateInstance(item); lab1.CountExceptions(instance); } foreach (var item in nonCriticalExceptions) { var instance = (Exception)Activator.CreateInstance(item); lab1.CountExceptions(instance); } // assert Assert.AreEqual(lab1.CounterCriticalExceptions, criticalExceptions.Count); Assert.AreEqual(lab1.CounterNotCriticalExceptions, nonCriticalExceptions.Count); }
private void Awake() { Instance = this; }
public void Lab1Test() { var bytes = File.ReadAllBytes(@"C:\Repos\Simple_compression_algorithms\Simple_compression_algorithms\Simple_compression_algorithms\Resources\house_1.ppm"); var compressed = Lab1.LZ77(bytes); }
public static void Main() { // User input char choice; Lab1 lab = new Lab1(); do { // Print menu Console.WriteLine("Hello World!! My First C# App"); Console.WriteLine("Options\n-----------------------------"); Console.WriteLine("1 - Import Words From File"); Console.WriteLine("2 - Bubble Sort words"); Console.WriteLine("3 - LINQ/Lambda Sort words"); Console.WriteLine("4 - Count the Distinct Words"); Console.WriteLine("5 - Take the First 10 Words"); Console.WriteLine("6 - Get the number of words that start with 'j' and display count"); Console.WriteLine("7 - Get and display words that end with 'd' and display the count"); Console.WriteLine("8 - Get and display words that are greater than 4 characters long and display the count"); Console.WriteLine("9 - Get and display words that are less than 3 characters long and start with the letter 'a' and display the count"); Console.WriteLine("x - Exit"); Console.Write("\nMake a Selection: "); // Get user input choice = Console.ReadLine().ToLower()[0]; Console.Clear(); // Do what user wanted switch (choice) { case '1': // Option 1 - Input words from file - DONE lab.ReadFile(); Console.WriteLine(); break; case '2': // Option 2 - Bubble Sort words - DONE Console.WriteLine(BubbleSort(lab.words)); Console.WriteLine(); break; case '3': // Option 3 - Lambda Sort lab.LambdaSort(); Console.WriteLine(); break; case '4': // Option 4 - Count distinct words - DONE lab.Distinct(); Console.WriteLine(); break; case '5': // Option 5 - First 10 words - DONE lab.Display(); Console.WriteLine(); break; case '6': // Option 6 - start with 'j' - DONE lab.StartJ(); Console.WriteLine(); break; case '7': // Option 7 - end with 'd' - DONE lab.EndD(); Console.WriteLine(); break; case '8': // Option 8 - greater than 4 characters long - DONE lab.GreaterThan4(); Console.WriteLine(); break; case '9': // Option 9 - Less than 3 characters long and starts with 'a' - DONE lab.LessThan3(); Console.WriteLine(); break; case 'x': // Option x - quit break; default: // Default Option Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Invalid Option!"); Console.WriteLine(); Console.ResetColor(); break; } } while (choice != 'x'); }
/*------------------------------------------------------------------------------------------------------------------ * -- FUNCTION: Start * -- * -- DATE: January 11, 2018 * -- * -- DESIGNER: Michael Goll * -- * -- PROGRAMMER: Michael Goll * -- * -- NOTES: * -- Initializes the default text of the UI. * -- Initializes the array of values to default calculated values. * ----------------------------------------------------------------------------------------------------------------------*/ void Start() { textTitle.text = "Hull"; dc = dco.GetComponent <Lab1>(); values = dc.getBoatFloats(); }
public static void Krylov(double[][] A, double start, double end, double eps, out double[] self_values, out double[][] self_vectors) { self_values = null; self_vectors = null; if (A == null || A.Count() == 0) { return; } if (A.Count() != A[0].Count()) { return; } double[][] y = new double[A.Count() + 1][]; for (int i = 0; i < y.Count(); i++) { y[i] = new double[A.Count()]; for (int j = 0; j < y[i].Count(); j++) { if (i == 0) { if (j == 0) { y[i][j] = 1; } else { y[i][j] = 0; } } else { y[i] = Matrix_multiplication(A, y[i - 1]); } } } double[][] p_matrix = new double[y.Count() - 1][]; for (int i = 0; i < p_matrix.Count(); i++) { p_matrix[i] = new double[p_matrix.Count() + 1]; for (int j = 0; j < p_matrix.Count(); j++) { p_matrix[i][j] = y[y.Count() - 2 - j][i]; } p_matrix[i][p_matrix.Count()] = y[y.Count() - 1][i]; } double[] p = Lab1.Gauss_main(p_matrix); Func <double, double> lambda_function = delegate(double lambda) { double lambda_root = Math.Pow(lambda, p.Count()); for (int i = 0; i < p.Count() - 1; i++) { lambda_root -= p[i] * Math.Pow(lambda, p.Count() - 1 - i); } lambda_root -= p[p.Count() - 1]; return(lambda_root); }; self_values = Lab2.Chords_multi(lambda_function, p.Count(), start, end, eps); double[][] q = new double[self_values.Count()][]; for (int i = 0; i < q.Count(); i++) { q[i] = new double[q.Count()]; for (int j = 0; j < q[i].Count(); j++) { if (j == 0) { q[i][j] = 1; } else { q[i][j] = self_values[i] * q[i][j - 1] - p[j - 1]; } } } double[][] x = new double[self_values.Count()][]; for (int i = 0; i < x.Count(); i++) { x[i] = y[y.Count() - 2]; for (int j = 0; j < x[i].Count() - 1; j++) { x[i] = Matrix_addition(x[i], Matrix_multiplication(y[y.Count() - 3 - j], q[i][j + 1])); } } self_vectors = x; }
static void Main(string[] args) { while (true) { Console.WriteLine("Введите номер лабораторной работы (1 - 8, 10; 0 - для выхода из приложения)"); switch (Console.ReadLine()) { case "0": { Console.WriteLine("Завершить работу приложения? (y/n)"); while (true) { switch (Console.ReadLine()) { case "y": return; case "n": break; default: continue; } break; } break; } case "1": { Console.WriteLine("Лабораторная работа #1\n" + "Выбор задания:\n" + "1. Даны x, y, z . Вычислить a, если...\n" + "2. Вычислить площадь треугольника по всем известным формулам"); switch (Console.ReadLine()) { case "1": { Lab1.RunTask1(); break; } case "2": { Lab1.RunTask2(); break; } default: break; } break; } case "2": { Console.WriteLine("Лабораторная работа #2"); Lab2.RunTask1(); break; } case "3": { Console.WriteLine("Лабораторная работа #3\n" + "Выбор задания:\n" + "1. Натуральное число p делится нацело на натуральное число q\n" + "2. Составить программу для вычисления функции"); switch (Console.ReadLine()) { case "1": { Lab3.RunTask1(); break; } case "2": { Lab3.RunTask2(); break; } } break; } case "4": { Console.WriteLine("Лабораторная работа #4"); Lab4.RunTask1(); break; } case "5": { Console.WriteLine("Лабораторная работа #5\n" + "Выбор задания:\n" + "1. Поиск минимального элемента из трех элементов\n" + "2. Найти сумму ряда при заданном n\n" + "3. Найти сумму бесконечного ряда при заданном eps\n" + "4. Дано натуральное число. Определить сколько раз в нем встречается цифра а"); switch (Console.ReadLine()) { case "1": { Lab5.RunTask1(); break; } case "2": { Lab5.RunTask2(); break; } case "3": { Lab5.RunTask3(); break; } case "4": { Lab5.RunTask4(); break; } } break; } case "6": { Console.WriteLine("Лабораторная работа #6\n" + "Выбор задания:\n" + "1. Нахождение минимального и максимального элементов заданной последователь-ности чисел.\n" + "Вывести на экран значения и порядковые номера искомых элементов\n" + "2. Программа для ввода/вывода в массив данных с различной длинной записей"); switch (Console.ReadLine()) { case "1": { Lab6.RunTask1(); break; } case "2": { Lab6.RunTask2(); break; } } break; } case "7": { Console.WriteLine("Лабораторная работа #7\n" + "Выбор задания:\n" + "1. Подсчет суммарного числа букв 'а' и букв 'b' в заданной строковой переменной. Вывести на экран каких букв больше\n" + "2. Поиск подстроки в заданной строке. В случае нахождения заданной подстроки необходимо удалить ее."); switch (Console.ReadLine()) { case "1": { Lab7.RunTask1(); break; } case "2": { Lab7.RunTask2(); break; } } break; } case "8": { Console.WriteLine("Лабораторная работа #8\n" + "Даны действительные числа a, b. Получить u = min(a, b-a), y = min(ab, a+b), k = min(u + v2, 3.14)"); Lab8.RunTask1(); break; } case "10": { Console.WriteLine("Лабораторная работа #10"); Lab10.RunTask(); break; } default: { break; } } } }