Question: Modify the following pseudo code in order to create a java method testAnd() that tests logic cases for an AND gate. No bit class is
Modify the following pseudo code in order to create a java method testAnd() that tests logic cases for an AND gate. No bit class is necessary, simply create the method that would test the cases and throw exceptions when cases are not met.
public void testAnd() {
if (new bit(0).and(new bit(0)).getValue() !=0) throw new Exception(0 AND 0 failed);
if (new bit(0).and(new bit(1)).getValue() !=0) throw new Exception(0 AND 1 failed);
if (new bit(1).and(new bit(0)).getValue() !=0) throw new Exception(1 AND 0 failed);
if (new bit(1).and(new bit(1)).getValue() !=1) throw new Exception(1 AND 1 failed);
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
