homework3-Car

# Class name

  • Car

# 作業說明

讓我們繼續控制車車吧!

# 輸入

  • 新增車車:new [車名] [x 座標] [y座標]
  • 移動車車:[方向(east, west, south, north)] [車名] [移動單位]
  • 消滅車車:destroy [車名]
  • 結束程式:end

# 輸出

  • 每台車的位置:[車名] [x 座標] [y 座標]
  • 兩兩車間的直線距離:[車名1] [車名2] [距離]

# 輸入範例

new Toyota -10 -20
east Toyota 16
north Toyota 17
new Lotus 3 7

new Nissan 5 -5
west Nissan 7
south Nissan 4
east Lotus 5
new Lexus 18 4
west Lexus 20
south Lexus 7
destroy Lotus
end

# 輸出範例

Toyota 6 -3
Nissan -2 -9
Lexus -2 -3
Toyota to Nissan 10.0
Toyota to Lexus 8.0
Nissan to Lexus 6.0

# hint

開根號函數:Math.sqrt()

次方函數:Math.pow()