public static void Test() { BlindAbacus test = new BlindAbacus(7, 7); for (int i = 0; i < 7; i++) { test[i].add(i); } Console.WriteLine(test); int line = 0; foreach (BlindAbacus.Row r in test) { Console.WriteLine(++line + "outer :" + r); if (line == 5) { try { foreach (BlindAbacus.Row s in test) { Console.WriteLine(" inner :" + s); } } catch (BlindAbacus.SomeoneThereException) { Console.WriteLine("Someone there"); } } } foreach (BlindAbacus.Row r in test) { Console.WriteLine(" outer :" + r); } }
public static void Test(string[] args) { BlindAbacus test = new BlindAbacus(2, 2); test[0].add(1); Console.WriteLine(test); try { test[0].add(1); } catch (BlindAbacus.IncorrectRowValueException) { Console.WriteLine("Row doesn't fit that many"); } Console.WriteLine(test); test[0].remove(1); try { test[0].remove(1); } catch (BlindAbacus.IncorrectRowValueException) { Console.WriteLine("Row doesn't fit that few"); } Console.WriteLine(test); }
public object Clone() { var result = new BlindAbacus(_base, _rows.Length); for (int i = 0; i < _rows.Length; ++i) { result._rows[i] = (Row)_rows[i].Clone(); } return(result); }
public static void Test() { BlindAbacus test1 = new BlindAbacus(3, 3), test2 = new BlindAbacus(4, 3); test1[2].add(2); test2[2].add(2); Console.WriteLine(test1); Console.WriteLine(); Console.WriteLine(test2); try { BlindAbacus test3 = test1 + test2; Console.WriteLine(test3); } catch (BlindAbacus.ComputationException) { Console.WriteLine("Incomparable bases"); } Console.WriteLine(test1); Console.WriteLine("Value : " + (int)test1); test1++; Console.WriteLine(test1); Console.WriteLine("Value : " + (int)test1); for (int i = 0; i < 8; i++) { test1++; } Console.WriteLine(test1); Console.WriteLine("Value : " + (int)test1); for (int j = 0; j < 3; j++) { for (int i = 0; i < 8; i++) { test1--; } Console.WriteLine(test1); Console.WriteLine("Value : " + (int)test1); } test1--; test1--; test1--; Console.WriteLine("<" + test1 + ">"); Console.WriteLine("Value : " + (int)test1); try { test1--; } catch (BlindAbacus.ComputationException) { Console.WriteLine("Mniej niż zero"); } }
public static void Test(string[] args) { BlindAbacus test = new BlindAbacus(4, 4); Console.WriteLine(test); Console.WriteLine(); foreach (BlindAbacus.Row temp in test) { temp.add(2); } Console.WriteLine(test); Console.WriteLine(); test[1].add(1); test[0].remove(1); Console.WriteLine(test); Console.WriteLine("Value " + (int)test); }
private static BlindAbacus WithBaseAndValue(int @base, int value) { int rows = 0; { int v = value; while (v != 0) { ++rows; v /= @base; } } var result = new BlindAbacus(@base, rows); for (int i = 0; i < rows; ++i) { result[i].add(value % @base); value /= @base; } return(result); }
public RowEnumerator(BlindAbacus parent) { _parent = parent; }