-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bit_test.java
67 lines (65 loc) · 2.3 KB
/
Bit_test.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package ComputerArchitecture;
/*
Jan Karl Galia
Comp. Architecture
HW 1: The Bit
*/
public class Bit_test{
public static void main(String[] args){
runTests();
}
public static void runTests(){
testSet();
testToggle();
testSet2();
testClear();
testGetValue();
testAnd();
testOr();
testXor();
testNot();
testToString();
}
public static void testSet(){//#1
new Bit().set(true);
new Bit().set(false);
}
public static void testToggle(){//#2
new Bit().toggle();
}
public static void testSet2(){//#3
new Bit().set();
}
public static void testClear(){//#4
new Bit().clear();
}
public static void testGetValue(){//#5
System.out.println("GetValue:"+ new Bit(0).getValue());
}
public static void testAnd(){//#6
System.out.println("0 AND 0:"+ new Bit(0).and(new Bit(0)).getValue());
System.out.println("0 AND 1:"+ new Bit(0).and(new Bit(1)).getValue());
System.out.println("1 AND 1:"+ new Bit(1).and(new Bit(1)).getValue());
System.out.println("1 AND 0:"+ new Bit(1).and(new Bit(0)).getValue());
}
public static void testOr(){//#7
System.out.println("0 OR 0:"+ new Bit(0).or(new Bit(0)).getValue());
System.out.println("0 OR 1:"+ new Bit(0).or(new Bit(1)).getValue());
System.out.println("1 OR 1:"+ new Bit(1).or(new Bit(1)).getValue());
System.out.println("1 OR 0:"+ new Bit(1).or(new Bit(0)).getValue());
}
public static void testXor(){//#8
System.out.println("0 XOR 0:"+ new Bit(0).xor(new Bit(0)).getValue());
System.out.println("0 XOR 1:"+ new Bit(0).xor(new Bit(1)).getValue());
System.out.println("1 XOR 1:"+ new Bit(1).xor(new Bit(1)).getValue());
System.out.println("1 XOR 0:"+ new Bit(1).xor(new Bit(0)).getValue());
}
public static void testNot(){//#9
System.out.println("NOT 0:" + new Bit(0).not().getValue());
System.out.println("NOT 1:" + new Bit(1).not().getValue());
}
public static void testToString(){//#10
System.out.println("ToStringOfFalse:"+ new Bit(0));
System.out.println("ToSTringOfTrue:"+ new Bit(1));
}
}