Commit e02e29ff by 李楚霏

task2 重命名变量

parent 5928922d
......@@ -16,31 +16,31 @@ export class Length {
return this.unit
}
parseTo(unitNode) {
let len = this
let unitLength = this
if (this.unit === 'yard') {
if (unitNode === 'f') {
len = new Length(this.value * 3, unitNode)
unitLength = new Length(this.value * 3, unitNode)
} else if (unitNode === 'inch') {
len = new Length(this.value * 36, unitNode)
unitLength = new Length(this.value * 36, unitNode)
}
}
if (this.unit === 'inch') {
if (unitNode === 'yard') {
len = new Length(this.value / 36, unitNode)
unitLength = new Length(this.value / 36, unitNode)
} else if (unitNode === 'f') {
len = new Length(this.value / 12, unitNode)
unitLength = new Length(this.value / 12, unitNode)
}
}
if (this.unit === 'f') {
if (unitNode === 'yard') {
len = new Length(this.value / 3, unitNode)
unitLength = new Length(this.value / 3, unitNode)
} else if (unitNode === 'inch') {
len = new Length(this.value * 12, unitNode)
unitLength = new Length(this.value * 12, unitNode)
}
}
return len
return unitLength
}
}
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 sign in to comment