I am stuck on the level “How Much”. I thought I had the right code.
# Calculate the perimeter and the area of the garden
# and pay the fair price for that.
# The prices for fences and lawns.
fencePrice = 3 # per meter.
lawnPrice = 2 # per square meter.
# You need the foreman.
foreman = hero.findNearest(hero.findFriends())
corners = foreman.corners
# Get the information about the garden.
bottomLeft = corners.bottomLeft
topRight = corners.topRight
# Calculate the size of the garden.
width = topRight.x - bottomLeft.x
height = topRight.y - bottomLeft.y
# Find the perimeter of the garden (meters):
perimeter = (width + height) * 2
# Use fencePrice and calculate the fence cost:
fencePrice = 3 * perimeter
# Find the area of the garden (square meters):
area = width * height
# Use lawnPrice and calculate the lawn cost:
llawnPrice = area * 2
# The total cost is the sum of the fence and the lawn costs
totalCost = 0 # Δ Update this with the final price!
totalCost = lawnPrice + fencePrice
hero.say("The total price is " + totalCost)
# Pay the bill.
foreman.bill(totalCost)