' Cargo Crates
' Copyright (c) 2012 Nonki Takahashi
'
' Calculate the level that a boat will sit in the water as you add cargo to it.
' Assume the boat has a length of 50 [m] and width of 5 [m] and has vertical sides,
' and its unloaded mass is 100 [t].
' If cargo crates are 2 x 2 x 5 [m] and weigh 5 [ton] each, how many crates can
' it hold to not exceed a total draft of 4 [m].
' Do a graphical display of the boat and crates to scale as it is loaded.
GraphicsWindow.Width = 600
GraphicsWindow.Height = 400
GraphicsWindow.BackgroundColor = "LightBlue"
SetCargoColor()
DrawPort()
AddBoat()
area = 5 * 50 ' area of boat base [m^2]
weight = 100 ' total weight of boat [t] = [m^3 of water]
draft = weight / area ' [m]
xBoat = 50
yBoat = 300 + (draft * 10)
MoveBoat()
AddWater()
AddData()
While draft < 4
AddCargo()
weight = 100 + nCargo * 5 ' [t]
draft = weight / area ' [m]
yBoat = 300 + (draft * 10)
MoveBoat()
Shapes.SetText(oNumCargo, nCargo)
Shapes.SetText(oWeight, weight + " [t]")
Shapes.SetText(oDraft, draft + " [m]")
If nCargo <= 20 Or 160 < nCargo Then
Program.Delay(200)
EndIf
EndWhile