public void PolinomialAddTests(string input, string expected) { var value = (INDimensionalVector)Factory.FactoryMethod(input); var actual = value.Add(value).ToString(); Assert.AreEqual(actual, expected); }
public void Main(SolutionFactory Factory) { Console.WriteLine( @"Многочлены Введите через пробел коэффиценты cначала первого потом второго многочлена:"); var value1 = Console.ReadLine(); var value2 = Console.ReadLine(); var polinom1 = (IPolynomial)Factory.FactoryMethod(value1); var polinom2 = (IPolynomial)Factory.FactoryMethod(value2); DoOperations(polinom1, polinom2); TakeCoeff(polinom1); Console.Write("Получить коэффицент первого полинома на позиции "); var index = Console.ReadLine(); //if() Console.WriteLine(); if (int.Parse(index) >= polinom1.Count) { Console.WriteLine("Такой коэффицент отсутствует"); } else { Console.WriteLine(polinom1[int.Parse(index)]); } }
public void SimpleTests(string value1, string value2, string expected) { var vector1 = (IThreeDVector)Factory.FactoryMethod(value1); var vector2 = (IThreeDVector)Factory.FactoryMethod(value2); var actual = vector1.VectorMultiply(vector2).ToString(); Assert.AreEqual(expected, actual); }
private IPlayingCard GetCard(SolutionFactory Factory) { CardValue Value = (CardValue)GetValueOrRankOfCard <CardValue>("card rank number"); CardSuit Suit = (CardSuit)GetValueOrRankOfCard <CardSuit>("card suit number"); return((IPlayingCard)Factory.FactoryMethod(Value, Suit)); }
public void RationalFractionStringAddTests(string num1, string num2, string expected) { var value1 = (IRationalFraction)factory.FactoryMethod(num1); var value2 = (IRationalFraction)factory.FactoryMethod(num2); var actual = value1.Add(value2); Assert.AreEqual(expected, actual.ToString()); }
private ICounter GetCounterObj(SolutionFactory Factory) { Console.WriteLine("Enter the borders this counter:"); int border1 = GetBorder("Border 1 - "); var border2 = GetBorder("Border 2 - "); return((ICounter)Factory.FactoryMethod(border1, border2)); }
public void Main(SolutionFactory Factory) { var obj = (IChainList)Factory.FactoryMethod(); AddToList(obj); DeleteStringFromObjByValue(obj); DeleteListStartingFrom(obj); ClearAllList(obj); }
private IRectangle GetRectangleObj(SolutionFactory Factory) { Console.WriteLine("Enter the rectangle data"); var x = GetValue("X - "); var y = GetValue("Y - "); var width = GetValue("Width - "); var heght = GetValue("Height - "); return((IRectangle)Factory.FactoryMethod(x, y, width, heght)); }
public void Main(SolutionFactory Factory) { Console.WriteLine( @"Комплексные числа Введите поочередно 2 комплексных числа в любом из следующих форматов: 1 + 2i, 1, 2i, i"); Console.WriteLine(); Console.WriteLine(); var first = (IComplexNumber)Factory.FactoryMethod(Console.ReadLine()); var second = (IComplexNumber)Factory.FactoryMethod(Console.ReadLine()); Console.WriteLine(); Console.WriteLine($"Сумма этих чисел равна {first.Add(second)}"); Console.WriteLine(); Console.WriteLine($"Разность этих чисел равна {first.Sub(second)}"); Console.WriteLine(); Console.WriteLine($"Произведение этих чисел равно {first.Multiply(second)}"); }
public void Main(SolutionFactory Factory) { var obj = (IMessageLog)Factory.FactoryMethod(); Console.WriteLine("Simple demonstration"); string message = EnterMessage(obj); string name = EnterName(obj); string comment = EnterComment(obj); AddSaveOpenFile(obj, message, name, comment); }
public void Main(SolutionFactory Factory) { Console.WriteLine("Enter the three coordinates of the first vector separated by a space"); var vector1 = (IThreeDVector)Factory.FactoryMethod(Console.ReadLine()); Console.WriteLine("Enter the three coordinates of the second vector separated by a space"); var vector2 = (IThreeDVector)Factory.FactoryMethod(Console.ReadLine()); Console.WriteLine(); Console.WriteLine($"The Sum of the vectors is {vector1.Add(vector2)}"); Console.WriteLine(); Console.WriteLine($"The vectors difference is {vector1.Sub(vector2)}"); Console.WriteLine(); Console.WriteLine($"vector multiply is {vector1.VectorMultiply(vector2)}"); Console.WriteLine(); Console.WriteLine($"scalar multiply is {vector1.ScalarMultiply(vector2)}"); Console.WriteLine(); CompareLengths(vector1, vector2); Console.WriteLine(); GetCoordinateByIndex(vector1); }
private IOneDArray CreateObj(SolutionFactory Factory) { var startIndex = 0; var length = 1; Console.WriteLine("Create an array"); Console.Write("Starting index - "); int.TryParse(Console.ReadLine(), out startIndex); Console.Write("Array length starting at given index - "); int.TryParse(Console.ReadLine(), out length); return((IOneDArray)Factory.FactoryMethod(startIndex, length)); }
private IOneDStringArray CreateObj(SolutionFactory Factory) { Console.Write("Enter the length of the array to be created - "); var length = 0; if (int.TryParse(Console.ReadLine(), out length) && length >= 0) { Console.WriteLine(); return((IOneDStringArray)Factory.FactoryMethod(length)); } Console.WriteLine("Incorrect data entered. Try again"); return(CreateObj(Factory)); }
public void Main(SolutionFactory Factory) { Console.WriteLine( @"Рациональные дроби Введите поочередно 2 рациональных дроби в любом из следующих форматов: 1/2, 24/7"); Console.WriteLine(); Console.WriteLine(); var first = (IRationalFraction)Factory.FactoryMethod(Console.ReadLine()); var second = (IRationalFraction)Factory.FactoryMethod(Console.ReadLine()); Console.WriteLine(); Console.WriteLine($"Сумма этих чисел равна {first.Add(second)}"); Console.WriteLine(); Console.WriteLine($"Разность этих чисел равна {first.Sub(second)}"); Console.WriteLine(); Console.WriteLine($"Произведение этих чисел равно {first.Multiply(second)}"); Console.WriteLine(); Console.WriteLine($"Частное этих чисел равно {first.Division(second)}"); }
public void Main(SolutionFactory Factory) { var obj = GetRectangleObj(Factory); Console.WriteLine(); obj.Print(); var testObj = (IRectangle)Factory.FactoryMethod(0, 0, 5, 5); Console.WriteLine(); TestIntersect(obj, testObj); Console.WriteLine(); FindRectangleContains(obj, testObj); }
private ISquareMatrix CreateMatrix(SolutionFactory Factory) { Console.Write("Enter the rank of the matrix\r\n and a random matrix with this rank will be generated - "); try { return((ISquareMatrix)Factory.FactoryMethod(int.Parse(Console.ReadLine()))); } catch { Console.WriteLine("Please enter valid data!"); Console.WriteLine(); return(CreateMatrix(Factory)); } }
private IMailingAddress GetObj(SolutionFactory Factory) { var post = (IMailingAddress)Factory.FactoryMethod(); Console.Write("Enter company name "); post.Name = Console.ReadLine(); Console.Write("Enter city "); post.City = Console.ReadLine(); Console.Write("Enter street "); post.Street = Console.ReadLine(); Console.Write("Enter home address "); post.HomeAddress = Console.ReadLine(); Console.Write("Enter postal code "); post.PostalCode = Console.ReadLine(); return(post); }
private ITriangleABC GetObj(SolutionFactory Factory) { Console.WriteLine("Enter three side of triangle"); double ab = 0; double bc = 0; double ca = 0; if (double.TryParse(Console.ReadLine(), out ab) && double.TryParse(Console.ReadLine(), out bc) && double.TryParse(Console.ReadLine(), out ca) && ab > 0 && bc > 0 && ca > 0) { return((ITriangleABC)Factory.FactoryMethod(ab, bc, ca)); } Console.WriteLine(); Console.WriteLine("Please enter valid data"); return(GetObj(Factory)); }
public void Main(SolutionFactory Factory) { int service = 0; Console.WriteLine( @"Класс Дата Введите некоторую дату в следующем формате: 01.01.2001"); Console.WriteLine(); Console.WriteLine(); var first = (IDate)Factory.FactoryMethod(); first.SetDate(Console.ReadLine()); Console.WriteLine($"Вы ввели дату {first.ToString()}"); Console.WriteLine(); first.AddOneDay(); Console.WriteLine($"Добавим один день - {first.ToString()}"); Console.WriteLine(); first.ReduceOneDay(); Console.WriteLine($"Убавим один день - {first.ToString()}"); Console.WriteLine(); Console.Write($"Теперь добавим дней к текущей дате "); var addDays = Console.ReadLine(); if (!(string.IsNullOrEmpty(addDays) || string.IsNullOrWhiteSpace(addDays)) && int.TryParse(addDays, out service)) { first.AddDays(service); } Console.WriteLine(); Console.WriteLine(first.ToString()); }
private INDimensionalVector EnterVector(SolutionFactory Factory) { Console.WriteLine("Space separated vector coordinates"); return((INDimensionalVector)Factory.FactoryMethod(Console.ReadLine())); }
public void ComplexNumberAddTests(double real1, double imagin1, double real2, double imagin2, string expected) { var value1 = (IComplexNumber)factory.FactoryMethod(real1, imagin1); var value2 = (IComplexNumber)factory.FactoryMethod(real2, imagin2); var actual = value1.Add(value2); Assert.AreEqual(expected, actual.ToString()); }
public void DateSetDateTest(string input, string expected) { var value = (IDate)Factory.FactoryMethod(input); Assert.AreEqual(expected, value.ToString()); }