- ...
This commit is contained in:
parent
495c6447d0
commit
f6f422abcd
@ -203,6 +203,9 @@ class LogicFunction implements JsonSerializable
|
||||
public static function isCorrectDNF(array $input_vars, string $exp): bool
|
||||
{
|
||||
$exp = trim($exp); // trim spaces
|
||||
if ($exp === "0") {
|
||||
return true;
|
||||
}
|
||||
$minterms = explode("|", $exp); // break up the expression into minterms
|
||||
$minterms = array_map(fn($mt) => trim($mt, " ()\t"), $minterms); // strip the parentheses off the minterms
|
||||
$minterms = array_map(fn($mt) => str_replace(" ", "", $mt), $minterms); // remove spaces
|
||||
@ -250,7 +253,12 @@ class LogicFunction implements JsonSerializable
|
||||
$minterms[] = $term;
|
||||
}
|
||||
}
|
||||
return join(" | ", $minterms);
|
||||
|
||||
$dnf = join(" | ", $minterms);
|
||||
if ($dnf === "") {
|
||||
$dnf = "0";
|
||||
}
|
||||
return $dnf;
|
||||
}
|
||||
|
||||
public function drawNetwork(string $outvar = "f"): string
|
||||
|
||||
@ -15,9 +15,6 @@ class LogicFunctionTask extends LogicTaskBase
|
||||
$this->setCorrectAnswer($this->getLogicFunction()->getExpression());
|
||||
} else {
|
||||
$dnf = $this->getLogicFunction()->toDNF();
|
||||
if ($dnf === "") {
|
||||
$dnf = "0";
|
||||
}
|
||||
$this->setCorrectAnswer($dnf);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user