public static void Run() { Console.WriteLine("<Observer Pattern Example>"); Console.WriteLine(); var left = Console.CursorLeft; var top = Console.CursorTop + 1; DrawView(); var cLeft = Console.CursorLeft; var cTop = Console.CursorTop; var view = new View(left + 17, top, cLeft, cTop); var hexa = new Hexa(view, left + 17, top + 6, cLeft, cTop); var octal = new Octal(view, left + 17, top + 4, cLeft, cTop); var binary = new Binary(view, left + 17, top + 2, cLeft, cTop); ; view.State = 15; Thread.Sleep(200); view.State = 10; Thread.Sleep(200); view.State = 7; Console.WriteLine(); Console.WriteLine("</Observer Pattern Example>"); }
public static Numeric_Base Decode(char choise) { Numeric_Base numeric_Base; switch (choise) { case 'b': numeric_Base = new Binary(); break; case 'o': numeric_Base = new Octal(); break; case 'd': numeric_Base = new Decimal(); break; case 'x': numeric_Base = new Hexadecimal(); break; default: numeric_Base = null; break; } return(numeric_Base); }
public void Octal_8_is_decimal_0() { Assert.Equal(0, Octal.ToDecimal("8")); }
public void Octal_carrot_is_decimal_0() { Assert.Equal(0, Octal.ToDecimal("carrot")); }
public void Octal_011_is_decimal_9() { Assert.Equal(9, Octal.ToDecimal("011")); }
public void Octal_1_is_decimal_1() { Assert.Equal(1, Octal.ToDecimal("1")); }
public void Octal_1234567_is_decimal_342391() { Assert.Equal(342391, Octal.ToDecimal("1234567")); }
public void Octal_7777_is_decimal_4095() { Assert.Equal(4095, Octal.ToDecimal("7777")); }
public void Octal_130_is_decimal_88() { Assert.Equal(88, Octal.ToDecimal("130")); }
public void Octal_17_is_decimal_15() { Assert.Equal(15, Octal.ToDecimal("17")); }
public void Octal_10_is_decimal_8() { Assert.Equal(8, Octal.ToDecimal("10")); }
public void Octal_can_convert_formatted_strings() { Assert.That(Octal.ToDecimal("011"), Is.EqualTo(9)); }
public void Invalid_octal_is_decimal_0(string invalidValue) { Assert.That(Octal.ToDecimal(invalidValue), Is.EqualTo(0)); }
public int Octal_converts_to_decimal(string value) { return(Octal.ToDecimal(value)); }
static void Main(string[] args) { Number number = null; Number output = null; Number number1 = null; Number number2 = null; string inputValue1 = "", inputValue2 = ""; bool bin = false; bool octa = false; bool hex = false; Console.WriteLine("*******************************************************************\n"); Console.WriteLine($" CALCULATOR \n"); Console.WriteLine("*******************************************************************\n"); Console.WriteLine("Enter the Number Type: Hexadecimal(H)/Binary(B)/Octal(O): \n"); ConsoleKeyInfo userNumType = Console.ReadKey(); if (char.Parse(userNumType.KeyChar.ToString()) == 'H') { Console.WriteLine("\nYou have chosen Hexadecimal as input type\n"); number = new Hexadecimal(); Console.WriteLine("*******************************************************************\n"); Console.WriteLine("Options: \n 1. Operations 2. Conversions\n"); Console.WriteLine("Enter your option: "); ConsoleKeyInfo userOptions = Console.ReadKey(); if ((char.IsDigit(userOptions.KeyChar) && int.Parse(userOptions.KeyChar.ToString()) == 2)) { hex = true; Hexconverter(); } if (char.IsDigit(userOptions.KeyChar) && int.Parse(userOptions.KeyChar.ToString()) == 1) { hex = true; BinOperation(); } } else if (char.Parse(userNumType.KeyChar.ToString()) == 'O') { Console.WriteLine("\n*******************************************************************\n"); Console.WriteLine("\nYou have chosen Octal as input type"); number = new Octal(); Console.WriteLine("Options: \n 1. Operations 2. Conversions\n"); Console.WriteLine("Enter your option: "); ConsoleKeyInfo userOptions = Console.ReadKey(); if ((char.IsDigit(userOptions.KeyChar) && int.Parse(userOptions.KeyChar.ToString()) == 2)) { octa = true; Octconverter(); } if (char.IsDigit(userOptions.KeyChar) && int.Parse(userOptions.KeyChar.ToString()) == 1) { octa = true; BinOperation(); } } else if (char.Parse(userNumType.KeyChar.ToString()) == 'B') { Console.WriteLine("\n*******************************************************************\n"); Console.WriteLine("\nYou have chosen Binary as input type"); number = new Binary(); Console.WriteLine("Options: \n 1. Operations 2. Conversions\n"); Console.WriteLine("Enter your option: "); ConsoleKeyInfo userOptions = Console.ReadKey(); if ((char.IsDigit(userOptions.KeyChar) && int.Parse(userOptions.KeyChar.ToString()) == 2)) { bin = true; Binconverter(); } if (char.IsDigit(userOptions.KeyChar) && int.Parse(userOptions.KeyChar.ToString()) == 1) { bin = true; BinOperation(); } } Console.WriteLine("Enter the input"); Console.WriteLine("Press 'E' to exit the process...\n"); while (Console.ReadKey().Key != ConsoleKey.E) { }
public void Octal_6789_is_decimal_0() { Assert.Equal(0, Octal.ToDecimal("6789")); }
public void Octal_abc1z_is_decimal_0() { Assert.Equal(0, Octal.ToDecimal("abc1z")); }
public void Octal_2047_is_decimal_1063() { Assert.Equal(1063, Octal.ToDecimal("2047")); }