current in Wire cannot be null (0 instead)
This commit is contained in:
parent
6ae15ea149
commit
a119ebf0d2
@ -64,7 +64,6 @@ export class Junction {
|
|||||||
return this.wires
|
return this.wires
|
||||||
.filter(wire => wire.traverse(this) !== plus)
|
.filter(wire => wire.traverse(this) !== plus)
|
||||||
.map(wire => wire.current)
|
.map(wire => wire.current)
|
||||||
.filter(current => current !== null)
|
|
||||||
.reduce((a, b) => a + b, 0);
|
.reduce((a, b) => a + b, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import {RESISTANCE_MIN} from '../circuit/Circuit';
|
|||||||
|
|
||||||
export class Wire {
|
export class Wire {
|
||||||
|
|
||||||
current: number | null = null;
|
current: number = 0;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
readonly start: Junction,
|
readonly start: Junction,
|
||||||
@ -18,6 +18,10 @@ export class Wire {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get absCurrent(): number {
|
||||||
|
return Math.abs(this.current);
|
||||||
|
}
|
||||||
|
|
||||||
toString() {
|
toString() {
|
||||||
if (this.start.part === this.end.part && this.name !== null) {
|
if (this.start.part === this.end.part && this.name !== null) {
|
||||||
return `'${this.start.part}' "${this.name}"`;
|
return `'${this.start.part}' "${this.name}"`;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user