質問編集履歴
1
削除のため
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,78 +1 @@
|
|
1
|
-
### 前提
|
2
|
-
|
3
|
-
Javaで否定論理積をもとめるプログラムを作りたい
|
4
|
-
|
5
|
-
### 実現したいこと
|
6
|
-
|
7
|
-
|
8
|
-
- [ ] 否定論理積を求める
|
9
|
-
|
10
|
-
### 発生している問題・エラーメッセージ
|
11
|
-
何を書けばいいかが分からない
|
12
|
-
|
13
|
-
|
14
|
-
### 該当のソースコード
|
15
|
-
|
16
|
-
```
|
17
|
-
public enum Bit {
|
18
|
-
_0_,_1_;
|
19
|
-
}
|
20
|
-
```
|
21
|
-
```
|
22
|
-
ublic abstract class LogicCircuit{
|
23
|
-
|
24
|
-
|
1
|
+
******************************
|
25
|
-
protected Bit _1_ = Bit._1_;
|
26
|
-
private Bit output;
|
27
|
-
|
28
|
-
protected void setOutput(Bit output){
|
29
|
-
this.output = output;
|
30
|
-
}
|
31
|
-
public Bit getOutput(){
|
32
|
-
return this.output;
|
33
|
-
}
|
34
|
-
}
|
35
|
-
```
|
36
|
-
```
|
37
|
-
public class And extends LogicCircuit{
|
38
|
-
|
39
|
-
public And( Bit x, Bit y ){
|
40
|
-
if( x == _0_ && y == _0_ ){
|
41
|
-
setOutput( _0_ );
|
42
|
-
} else if( x == _0_ && y == _1_ ){
|
43
|
-
setOutput( _0_ );
|
44
|
-
} else if( x == _1_ && y == _0_ ){
|
45
|
-
setOutput( _0_ );
|
46
|
-
} else if( x == _1_ && y == _1_ ){
|
47
|
-
setOutput( _1_ );
|
48
|
-
}
|
49
|
-
}
|
50
|
-
|
51
|
-
}
|
52
|
-
```
|
53
|
-
```
|
54
|
-
public class Not extends LogicCircuit{
|
55
|
-
public Not( Bit x ){
|
56
|
-
if( x == _0_ ){
|
57
|
-
setOutput( _1_ );
|
58
|
-
} else if( x == _1_ ){
|
59
|
-
setOutput( _0_ );
|
60
|
-
}
|
61
|
-
}
|
62
|
-
}
|
63
|
-
```
|
64
|
-
分からないところ(b1=,b2=の後)
|
65
|
-
```
|
66
|
-
public class Nand extends LogicCircuit{
|
67
|
-
public Nand(Bit x,Bit y){
|
68
|
-
Bit b1=
|
69
|
-
Bit b2=
|
70
|
-
setOutput(b2);
|
71
|
-
}
|
72
|
-
}
|
73
|
-
```
|
74
|
-
### 試したこと
|
75
|
-
|
76
|
-
Bit b1= x && y;
|
77
|
-
Bit b2= !b1;
|
78
|
-
|