public void ToBinary_Test() { var sut = new ToBinary(); var ToBinary_Ergebnis = sut.ToBinary_Funktion(2); Assert.AreEqual(ToBinary_Ergebnis[0], 1); Assert.AreEqual(ToBinary_Ergebnis[1], 0); }
public IActionResult Post(ToTraslate Traslate) { if (!ModelState.IsValid) { return(BadRequest()); } if (!Traslate.OriginFormatType.Contains("MORSE") && !Traslate.OriginFormatType.Equals("BINARY") && !Traslate.OriginFormatType.Equals("TEXT")) { return(BadRequest("Formato origen no soportado")); } if (!Traslate.TargetFormatType.Equals("MORSE") && !Traslate.TargetFormatType.Equals("BINARY") && !Traslate.TargetFormatType.Equals("TEXT")) { return(BadRequest("Formato destino no soportado")); } if (Traslate.TargetFormatType.Equals(Traslate.OriginFormatType)) { return(BadRequest("El formato de salida es igual al de entrada")); } TraslateBase traslate = new TraslateBase(); if (Traslate.TargetFormatType.Equals("MORSE")) { traslate = new ToMorse { toTraslate = Traslate } } ; else if (Traslate.TargetFormatType.Equals("BINARY")) { traslate = new ToBinary { toTraslate = Traslate } } ; else if (Traslate.OriginFormatType.Equals("MORSE") && Traslate.TargetFormatType.Equals("BINARY")) { return(BadRequest("Lo sentimos proceso en contrucción")); } else if (Traslate.OriginFormatType.Equals("BINARY") && Traslate.TargetFormatType.Equals("MORSE")) { return(BadRequest("Lo sentimos proceso en contrucción")); } else { return(BadRequest("Lo sentimos proceso en contrucción")); } traslate.Traslate(); return(Ok(traslate.toTraslate.TextTraslate)); }
static void Main(string[] args) { string userInput; try { ConsoleKey consoleKey = Console.ReadKey().Key; bool isAtrue = true; while (isAtrue) { DateTime now = new DateTime(); Console.WriteLine("Select function\n" + "1)Converton to Binar\n" + "2)Convertor from binary\n" + "3)Alarm Clock\n" ); userInput = Console.ReadLine(); if (userInput == "1") { ToBinary trans = new ToBinary(); Console.WriteLine("Введите число в десятичной системе счисления: "); int user = int.Parse(Console.ReadLine()); trans.TransferToBinary(user); Console.WriteLine(user); } else if (userInput == "2") { Console.WriteLine("Введите число в двоичной системе счисления: "); int user_input = Convert.ToInt32(Console.ReadLine()); FBinary converter = new FBinary(); converter.FromBinaryToTen(user_input); } else if (userInput == "3") { if (DateTime.Now == DateTime.Now) { Console.WriteLine("Ввовремя"); } } switch (consoleKey) { case ConsoleKey.Backspace: isAtrue = false; break; } } } catch (FormatException) { Console.WriteLine("Ошибка форматирования"); } catch (Exception) { Console.WriteLine("Ошибка!"); } }
public void Dispose() { fromBinary = null; toBinary = null; }
/// <summary> /// Main Method where execution starts /// </summary> /// <param name="args">String array</param> public static void Main(string[] args) { char condition; do { Console.WriteLine("Press 1 for : String Anagram"); Console.WriteLine("Press 2 for : Prime Numbers upto N"); Console.WriteLine("Press 3 for : Prime Palindromic Anagram Numbers"); Console.WriteLine("Press 4 for : Menu for Search and Sort"); Console.WriteLine("Press 5 for : Game of Guessing the number"); Console.WriteLine("Press 6 for : BinarySearch to search word from file"); Console.WriteLine("Press 7 for : Insertion sort for String Array"); Console.WriteLine("Press 8 for : Bubble sort for Integer Array"); Console.WriteLine("Press 9 for : Merge Sort for String"); Console.WriteLine("Press 10 for : Vending Machine"); Console.WriteLine("Press 11 for : Day Of the week of entered date"); Console.WriteLine("Press 12 for : Temperature Conversion"); Console.WriteLine("Press 13 for : Monthly Payment"); Console.WriteLine("Press 14 for : Square Root using Newton Method"); Console.WriteLine("Press 15 for : Convert number to Binary"); try { int ch = Convert.ToInt32(Console.ReadLine()); switch (ch) { case 1: Anagram a = new Anagram(); break; case 2: Prime p = new Prime(); break; case 3: PalPrimeAnagram p1 = new PalPrimeAnagram(); break; case 4: MenuForSearchSortAlgo mss = new MenuForSearchSortAlgo(); break; case 5: QuestionGame qg = new QuestionGame(); break; case 6: ReadFromFile rf = new ReadFromFile(); break; case 7: InsertionSortString in1 = new InsertionSortString(); break; case 8: BubbleSortInt bbi = new BubbleSortInt(); break; case 9: MergeString ms = new MergeString(); break; case 10: VendingMachine vm = new VendingMachine(); break; case 11: DayOfWeek dow = new DayOfWeek(); break; case 12: Temperature t = new Temperature(); break; case 13: MonthlyPayment mp = new MonthlyPayment(); break; case 14: SqrtNewtonMethod sq = new SqrtNewtonMethod(); break; case 15: ToBinary tb = new ToBinary(); break; default: break; } } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.WriteLine("enter Y for Main Menu / N to exit"); condition = Convert.ToChar(Console.ReadLine()); }while (condition == 'y'); }