Commit 5928922d by 李楚霏

task- 重命名,通过第一次测试

parent 76118ee0
export class Length {
value
unit
unitEnum = ['foot', 'yard', 'inch']
// unitEnum = ['foot', 'yard', 'inch']
constructor(val, uint) {
this.value = val
......@@ -15,29 +15,29 @@ export class Length {
getUint() {
return this.unit
}
parseTo(u) {
parseTo(unitNode) {
let len = this
if (this.unit === 'yard') {
if (u === 'f') {
len = new Length(this.value * 3, u)
} else if (u === 'inch') {
len = new Length(this.value * 36, u)
if (unitNode === 'f') {
len = new Length(this.value * 3, unitNode)
} else if (unitNode === 'inch') {
len = new Length(this.value * 36, unitNode)
}
}
if (this.unit === 'inch') {
if (u === 'yard') {
len = new Length(this.value / 36, u)
} else if (u === 'f') {
len = new Length(this.value / 12, u)
if (unitNode === 'yard') {
len = new Length(this.value / 36, unitNode)
} else if (unitNode === 'f') {
len = new Length(this.value / 12, unitNode)
}
}
if (this.unit === 'f') {
if (u === 'yard') {
len = new Length(this.value / 3, u)
} else if (u === 'inch') {
len = new Length(this.value * 12, u)
if (unitNode === 'yard') {
len = new Length(this.value / 3, unitNode)
} else if (unitNode === 'inch') {
len = new Length(this.value * 12, unitNode)
}
}
......
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