Commit e788fe53 authored by Chinmay Garde's avatar Chinmay Garde

Minor: Match style guide

parent 7eb83223
......@@ -17,27 +17,27 @@ class Expression extends EquationMember {
Constraint _createConstraint(
EquationMember /* rhs */ value, Relation relation) {
if (value is ConstantMember) {
return new Constraint(new Expression(
new List.from(this.terms), this.constant - value.value), relation);
return new Constraint(
new Expression(new List.from(terms), constant - value.value),
relation);
}
if (value is Variable) {
var newTerms = new List<Term>.from(this.terms)
..add(new Term(value, -1.0));
return new Constraint(new Expression(newTerms, this.constant), relation);
var newTerms = new List<Term>.from(terms)..add(new Term(value, -1.0));
return new Constraint(new Expression(newTerms, constant), relation);
}
if (value is Term) {
var newTerms = new List<Term>.from(this.terms)
var newTerms = new List<Term>.from(terms)
..add(new Term(value.variable, -value.coefficient));
return new Constraint(new Expression(newTerms, this.constant), relation);
return new Constraint(new Expression(newTerms, constant), relation);
}
if (value is Expression) {
var newTerms = value.terms.fold(new List<Term>.from(this.terms),
var newTerms = value.terms.fold(new List<Term>.from(terms),
(list, t) => list..add(new Term(t.variable, -t.coefficient)));
return new Constraint(
new Expression(newTerms, this.constant - value.constant), relation);
new Expression(newTerms, constant - value.constant), relation);
}
assert(false);
......@@ -55,21 +55,21 @@ class Expression extends EquationMember {
Expression operator +(EquationMember m) {
if (m is ConstantMember) {
return new Expression(new List.from(this.terms), this.constant + m.value);
return new Expression(new List.from(terms), constant + m.value);
}
if (m is Variable) {
return new Expression(
new List.from(this.terms)..add(new Term(m, 1.0)), this.constant);
new List.from(terms)..add(new Term(m, 1.0)), constant);
}
if (m is Term) {
return new Expression(new List.from(this.terms)..add(m), this.constant);
return new Expression(new List.from(terms)..add(m), constant);
}
if (m is Expression) {
return new Expression(new List.from(this.terms)..addAll(m.terms),
this.constant + m.constant);
return new Expression(
new List.from(terms)..addAll(m.terms), constant + m.constant);
}
assert(false);
......@@ -78,24 +78,24 @@ class Expression extends EquationMember {
Expression operator -(EquationMember m) {
if (m is ConstantMember) {
return new Expression(new List.from(this.terms), this.constant - m.value);
return new Expression(new List.from(terms), constant - m.value);
}
if (m is Variable) {
return new Expression(
new List.from(this.terms)..add(new Term(m, -1.0)), this.constant);
new List.from(terms)..add(new Term(m, -1.0)), constant);
}
if (m is Term) {
return new Expression(new List.from(this.terms)
..add(new Term(m.variable, -m.coefficient)), this.constant);
return new Expression(new List.from(terms)
..add(new Term(m.variable, -m.coefficient)), constant);
}
if (m is Expression) {
var copiedTerms = new List<Term>.from(this.terms);
var copiedTerms = new List<Term>.from(terms);
m.terms.forEach(
(t) => copiedTerms.add(new Term(t.variable, -t.coefficient)));
return new Expression(copiedTerms, this.constant - m.constant);
return new Expression(copiedTerms, constant - m.constant);
}
assert(false);
......@@ -103,14 +103,14 @@ class Expression extends EquationMember {
}
EquationMember operator *(double m) {
var terms = this.terms.fold(new List<Term>(), (list, term) => list
var newTerms = terms.fold(new List<Term>(), (list, term) => list
..add(new Term(term.variable, term.coefficient * m)));
return new Expression(terms, this.constant * m);
return new Expression(newTerms, constant * m);
}
EquationMember operator /(double m) {
var terms = this.terms.fold(new List<Term>(), (list, term) => list
var newTerms = terms.fold(new List<Term>(), (list, term) => list
..add(new Term(term.variable, term.coefficient / m)));
return new Expression(terms, this.constant / m);
return new Expression(newTerms, constant / m);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment