日期:2014-05-18  浏览次数:20859 次

if you take OO to the extreme -- which is, of course, completely ridiculous.
I mean, if you take OO to the extreme, that would require excluding all
 those evil procedural constructs like if statements and for loops, and
 write everything in terms of invoking object methods... like this
 monstrosity:
 
 class MyClass {
  void myMethod() {
  IntVariable i;
  ForLoopFactory.create(
  new IntSetter(i.address(), new Number(0)),
  new BooleanCondition(
  new LessThanComparator(i.address(),
  100)),
  new IntAdder(&i, 1),
  new IfStatement(
  new EqualComparator(i.address(),
  new Number(42)),
  new FunctionCaller(writeln.address(),
  new String("Found it!")),
  )
  ).execute();
  }
 }
 
 which is, of course, completely ridiculous.

------解决方案--------------------
9 个 new