有人可以告诉我为什么这不起作用吗?我不能为我的生活弄清楚它为什么没有。编译很好,看起来很好,这种方法对我来说无处不在......真的需要一些帮助,任何人都知道什么是错的?
set areatype to (choose from list {"Triagles", "Trapeziums"} with prompt "What would you like to calculate the area of?" with title "Area Calculator")
if areatype contains "Triangles" then
set height to text returned of (display dialog "What is the height of the triangle?" with title "Area Calculator" default answer "")
set base to text returned of (display dialog "What is the base of the triangle?" with title "Area Calculator" default answer "")
set area to (height * base) / 2
display dialog "Area = " & area & " units squared" with title "Area Calculator" buttons {"Cancel", "Go again"}
else
if areatype contains "Trapezium" then
set base1 to text returned of (display dialog "What is one base of the trapezium?" with title "Area Calculator" default answer "")
set base2 to text returned of (display dialog "What is the other base of the trapezium?" with title "Area Calculator" default answer "")
set area to ((a + b) / 2) * h
display dialog "Area = " & area & " units squared" with title "Area Calculator" buttons {"Cancel", "Go again"}
end if
end if
-Thanks
答案 0 :(得分:0)
查看代码中的第一行。你错误拼写三角形,你需要" s"在Trapeziums添加到"否则"代码中的一行。
on goAgain()
set areatype to (choose from list {"Triangles", "Trapeziums"} with prompt "What would you like to calculate the area of?" with title "Area Calculator")
if areatype contains "Triangles" then
set height to text returned of (display dialog "What is the height of the triangle?" with title "Area Calculator" default answer "")
set base to text returned of (display dialog "What is the base of the triangle?" with title "Area Calculator" default answer "")
set area to (height * base) / 2
display dialog "Area = " & area & " units squared" with title "Area Calculator" buttons {"Cancel", "Go again"}
if the button returned of the result is "Go again" then
goAgain()
else
return
end if
else
if areatype contains "Trapeziums" then
set base1 to text returned of (display dialog "What is one base of the trapezium?" with title "Area Calculator" default answer "")
set base2 to text returned of (display dialog "What is the other base of the trapezium?" with title "Area Calculator" default answer "")
set height2 to text returned of (display dialog "What is the height of the trapezium?" with title "Area Calculator" default answer "")
set area to ((base1 + base2) / 2) * height2
display dialog "Area = " & area & " units squared" with title "Area Calculator" buttons {"Cancel", "Go again"}
if the button returned of the result is "Go again" then
goAgain()
else
return
end if
end if
end if
end goAgain
goAgain()