diff options
Diffstat (limited to 'test/files/run/Course-2002-09.scala')
-rw-r--r-- | test/files/run/Course-2002-09.scala | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/test/files/run/Course-2002-09.scala b/test/files/run/Course-2002-09.scala index 87f91111d8..704f2ec0aa 100644 --- a/test/files/run/Course-2002-09.scala +++ b/test/files/run/Course-2002-09.scala @@ -13,11 +13,11 @@ object NoConstraint extends Constraint { } class Adder(a1: Quantity,a2: Quantity,sum: Quantity) extends Constraint { - def newValue = Triple(a1.getValue, a2.getValue, sum.getValue) match { - case Triple(Some(x1), Some(x2), _ ) => sum.setValue(x1 + x2, this) - case Triple(Some(x1), _ , Some(r)) => a2.setValue(r - x1, this) - case Triple(_ , Some(x2), Some(r)) => a1.setValue(r - x2, this) - case _ => + def newValue = (a1.getValue, a2.getValue, sum.getValue) match { + case (Some(x1), Some(x2), _ ) => sum.setValue(x1 + x2, this) + case (Some(x1), _ , Some(r)) => a2.setValue(r - x1, this) + case (_ , Some(x2), Some(r)) => a1.setValue(r - x2, this) + case _ => } def dropValue: Unit = { a1.forgetValue(this); a2.forgetValue(this); sum.forgetValue(this); @@ -29,13 +29,13 @@ class Adder(a1: Quantity,a2: Quantity,sum: Quantity) extends Constraint { class Multiplier(m1: Quantity, m2: Quantity, prod: Quantity) extends Constraint { - def newValue = Triple(m1.getValue, m2.getValue, prod.getValue) match { - case Triple(Some(0d), _ , _ ) => prod.setValue(0, this); - case Triple(_ , Some(0d), _ ) => prod.setValue(0, this); - case Triple(Some(x1), Some(x2), _ ) => prod.setValue(x1 * x2, this) - case Triple(Some(x1), _ , Some(r)) => m2.setValue(r / x1, this) - case Triple(_, Some(x2), Some(r)) => m1.setValue(r / x2, this) - case _ => + def newValue = (m1.getValue, m2.getValue, prod.getValue) match { + case (Some(0d), _ , _ ) => prod.setValue(0, this); + case (_ , Some(0d), _ ) => prod.setValue(0, this); + case (Some(x1), Some(x2), _ ) => prod.setValue(x1 * x2, this) + case (Some(x1), _ , Some(r)) => m2.setValue(r / x1, this) + case (_, Some(x2), Some(r)) => m1.setValue(r / x2, this) + case _ => } def dropValue: Unit = { m1.forgetValue(this); m2.forgetValue(this); prod.forgetValue(this); @@ -46,11 +46,11 @@ class Multiplier(m1: Quantity, m2: Quantity, prod: Quantity) } class Squarer(square: Quantity, root: Quantity) extends Constraint { - def newValue: Unit = Pair(square.getValue, root.getValue) match { - case Pair(Some(x), _ )if (x < 0) => sys.error("Square of negative number") - case Pair(Some(x), _ ) => root.setValue(Math.sqrt(x), this) - case Pair(_ , Some(x)) => square.setValue(x*x, this) - case _ => + def newValue: Unit = (square.getValue, root.getValue) match { + case (Some(x), _ )if (x < 0) => sys.error("Square of negative number") + case (Some(x), _ ) => root.setValue(Math.sqrt(x), this) + case (_ , Some(x)) => square.setValue(x*x, this) + case _ => } def dropValue: Unit = { square.forgetValue(this); root.forgetValue(this); @@ -60,9 +60,9 @@ class Squarer(square: Quantity, root: Quantity) extends Constraint { } class Eq(a: Quantity, b: Quantity) extends Constraint { - def newValue = (Pair(a.getValue, b.getValue): @unchecked) match { - case Pair(Some(x), _ ) => b.setValue(x, this); - case Pair(_ , Some(y)) => a.setValue(y, this); + def newValue = ((a.getValue, b.getValue): @unchecked) match { + case (Some(x), _ ) => b.setValue(x, this); + case (_ , Some(y)) => a.setValue(y, this); } def dropValue { a.forgetValue(this); b.forgetValue(this); |