public class multiply implements IConstraint
{
private variable multiplier;
private variable multiplicand;
private variable product;
public multiply(variable v1, variable v2, variable v3)
{
multiplier = v1;
multiplicand = v2;
product = v3;
multiplier.connect(this);
multiplicand.connect(this);
product.connect(this);
}
public void valueChanged()
{
if (multiplier.has_value() && multiplicand.has_value())
{
product.set_value(multiplier.get_value() * multiplicand.get_value(), this);
}
else if (multiplier.has_value() && product.has_value())
{
文章来源于领测软件测试网 https://www.ltesting.net/