Commit 5928922d by 李楚霏

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

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