Category : Pascal Source Code
Archive   : PASTUT.ZIP
Filename : ENCAP1.PAS

 
Output of file : ENCAP1.PAS contained in archive : PASTUT.ZIP
(* Chapter 15 - Program 1 *)
program Encapsulation_1;

type
Box = object
length : integer;
width : integer;
constructor Init(len, wid : integer);
procedure Set_Data(len, wid : integer);
function Get_Area : integer;
end;

constructor Box.Init(len, wid : integer);
begin
length := len;
width := wid;
end;

procedure Box.Set_Data(len, wid : integer);
begin
length := len;
width := wid;
end;

function Box.Get_Area : integer;
begin
Get_Area := length * width;
end;

var Small, Medium, Large : Box;

begin

Small.Init(8,8);
Medium.Init(10,12);
Large.Init(15,20);

WriteLn('The area of the small box is ',Small.Get_Area);
WriteLn('The area of the medium box is ',Medium.Get_Area);
WriteLn('The area of the large box is ',Large.Get_Area);

end.




{ Result of execution

The area of the small box is 64
The area of the medium box is 120
The area of the large box is 300

}

  3 Responses to “Category : Pascal Source Code
Archive   : PASTUT.ZIP
Filename : ENCAP1.PAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/