📄 geometry.adb
字号:
package body Geometry is function Distance (O: in Object) return Float is begin return Sqrt(O.Pos_X ** 2 + O.Pos_Y ** 2); end Distance; -- -- Object does not have area -- abstract subprogram cannot have a body -- -- function Area(O: in Object) return Float is -- begin -- return 0.0; -- end Area; -- -- Its OK Distace2 to have class-wide parameter -- as Distance function is the same for type derived from -- Object. -- function Distance2(OC: in Object'Class) return float is begin return Sqrt(OC.Pos_X ** 2 + OC.Pos_Y ** 2); end Distance2; function Area(C: in Circle) return Float is begin return Pi * C.Radius ** 2 * Pi; end Area; function Area(P: in Point) return Float is begin return 0.0; end; function Moment(OC: Object'Class) return Float is begin -- -- -- return OC.Pos_X * Area(OC); -- Prefixed notation return OC.Pos_X * OC.Area; end Moment; function MO(OC: in Object'Class) return Float is begin return MI(OC) + Area(OC) * Distance(OC) ** 2; end MO; function MI(C: in Circle) return Float is begin return Area(C) * Distance(C) ** 2 / 2.0; end MI; function MI(P: in Point) return Float is begin return 0.0; end MI; -- -- Add any Object to the List -- procedure Add_To_List (List: access Cell; OP: Pointer) is Local: access Cell := List; begin -- -- Find the end of the list -- loop if Local.Next = null then Local.Next.Element := OP; return; else Local := Local.Next; end if; end loop; end Add_To_List;end Geometry;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -