write my assignment 3264

Consider the interface below, implement two classes True and False where each of them implements the Bool class. The function logicalAnd is similar to the primitive && with no short circuiting, and the function ifThenElse accepts two CodeBlock objects and the first argument would be executed if the Bool object is True, second argument would be executed instead if the Bool object is False.

interface Bool {

  Bool logicalAnd();

  void ifThenElse(CodeBlock b1, CodeBlock b2);

}

For example, the code snippet below would print the string “bye world!”.

Bool b1 = new True();

Bool b2 = new False();

Bool b3 = b1.logicalAnd(b2);

b3.ifThenElse(new CodeBlock() {

 
"Not answered?"
Get the Answer