home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue66 / Construc / DrBob42_impl.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-01-03  |  5.1 KB  |  204 lines

  1. unit DrBob42_impl;
  2.  
  3. {This file was generated on 29 Dec 2000 10:32:07 GMT by version 03.03.03.C1.06}
  4. {of the Inprise VisiBroker idl2pas CORBA IDL compiler.                        }
  5.  
  6. {Please do not edit the contents of this file. You should instead edit and    }
  7. {recompile the original IDL which was located in the file                     }
  8. {C:\DrBob42\Drbob42.idl.                                                      }
  9.  
  10. {Delphi Pascal unit     : DrBob42_impl                                       }
  11. {derived from IDL module: DrBob42                                            }
  12.  
  13. interface
  14. uses
  15.   SysUtils,
  16.   CORBA,
  17.   DrBob42_i,
  18.   DrBob42_c;
  19.  
  20. type
  21.   TRates = class;
  22.   TAccount = class;
  23.   TMyAccount = class;
  24.   TADT = class;
  25.   TSeqAccount = class;
  26.  
  27.   TRates = class(TInterfacedObject, DrBob42_i.Rates)
  28.   protected
  29.     finterest_rate: Single;
  30.   public
  31.     constructor Create;
  32.     function interest_rate: Single;
  33.   end;
  34.  
  35.   TAccount = class(TInterfacedObject, DrBob42_i.Account)
  36.   protected
  37.     fbalance: Single;
  38.   public
  39.     constructor Create;
  40.     function balance: Single;
  41.     function get_rates(const myRates: DrBob42_i.Rates): Single;
  42.   end;
  43.  
  44.   TMyAccount = class(TInterfacedObject, DrBob42_i.MyAccount)
  45.   protected
  46.     fbalance: Single;
  47.   public
  48.     constructor Create;
  49.     procedure deposit(const amount: Single);
  50.     procedure withdraw(const amount: Single);
  51.     function  balance: Single;
  52.     function  get_rates(const myRates: DrBob42_i.Rates): Single;
  53.   end;
  54.  
  55.   TADT = class(TInterfacedObject, DrBob42_i.ADT)
  56.   protected
  57.     {******************************}
  58.     {*** User variables go here ***}
  59.     {******************************}
  60.   public
  61.     constructor Create;
  62.     procedure test(const one: DrBob42_i.Identifier;
  63.                      const two: DrBob42_i.EnumType;
  64.                      const three: DrBob42_i.StructType;
  65.                      const four: DrBob42_i.UnionType;
  66.                      const five: DrBob42_i.StructArray;
  67.                      const six: DrBob42_i.StructSequence);
  68.   end;
  69.  
  70.   TSeqAccount = class(TInterfacedObject, DrBob42_i.SeqAccount)
  71.   protected
  72.     {******************************}
  73.     {*** User variables go here ***}
  74.     {******************************}
  75.   public
  76.     constructor Create;
  77.     function  balance(const mySeq: DrBob42_i.IntSeq): Single;
  78.   end;
  79.  
  80.  
  81. implementation
  82. uses
  83.   Dialogs;
  84.  
  85. constructor TRates.Create;
  86. begin
  87.   inherited;
  88.   finterest_rate := 7;
  89.   ShowMessage('TRates.Create');
  90. end;
  91.  
  92. function  TRates.interest_rate: Single;
  93. begin
  94.   Result := finterest_rate;
  95. end;
  96.  
  97. constructor TAccount.Create;
  98. begin
  99.   inherited;
  100.   fbalance := 42;
  101.   ShowMessage('TAccount.Create');
  102. end;
  103.  
  104. function  TAccount.balance: Single;
  105. begin
  106.   Result := fbalance;
  107. end;
  108.  
  109. function  TAccount.get_rates(const myRates: DrBob42_i.Rates): Single;
  110. begin
  111.   Result := myRates.interest_rate
  112. end;
  113.  
  114. constructor TMyAccount.Create;
  115. begin
  116.   inherited;
  117.   fbalance := 0;
  118.   ShowMessage('TMyAccount.Create');
  119. end;
  120.  
  121. procedure TMyAccount.deposit(const amount: Single);
  122. begin
  123.   fbalance := fbalance + amount;
  124. end;
  125.  
  126. procedure TMyAccount.withdraw(const amount: Single);
  127. var
  128.   Error: TAccountError;
  129. begin
  130.   if amount <= 0 then
  131.   begin
  132.     writeln('Cannot withdraw negative amount ',amount:1:2);
  133.     Error := TAccountError.Create(amount,'Cannot withdraw negative amount %f');
  134.     raise EAccountException.Create(Error);
  135.   end
  136.   else
  137.     if fbalance <= 0 then
  138.     begin
  139.       writeln('Balance zero or negative: ',fbalance:1:2);
  140.       Error := TAccountError.Create(fbalance,'Balance zero or negative: %f');
  141.       raise EAccountException.Create(Error);
  142.     end
  143.     else
  144.       if amount > fbalance then
  145.       begin
  146.         writeln('Balance not enough: ',fbalance:1:2);
  147.         Error := TAccountError.Create(fbalance,'Balance not enough: %f');
  148.         raise EAccountException.Create(Error);
  149.       end
  150.       else
  151.         fbalance := fbalance - amount;
  152. end;
  153.  
  154. function  TMyAccount.balance: Single;
  155. begin
  156.   Result := fbalance;
  157. end;
  158.  
  159. function  TMyAccount.get_rates(const myRates: DrBob42_i.Rates): Single;
  160. begin
  161.   Result := myRates.interest_rate
  162. end;
  163.  
  164. constructor TADT.Create;
  165. begin
  166.   inherited;
  167.   { *************************** }
  168.   { *** User code goes here *** }
  169.   { *************************** }
  170. end;
  171.  
  172. procedure TADT.test(const one: DrBob42_i.Identifier;
  173.                       const two: DrBob42_i.EnumType;
  174.                       const three: DrBob42_i.StructType;
  175.                       const four: DrBob42_i.UnionType;
  176.                       const five: DrBob42_i.StructArray;
  177.                       const six: DrBob42_i.StructSequence);
  178. begin
  179.   { *************************** }
  180.   { *** User code goes here *** }
  181.   { *************************** }
  182. end;
  183.  
  184. constructor TSeqAccount.Create;
  185. begin
  186.   inherited;
  187.   { *************************** }
  188.   { *** User code goes here *** }
  189.   { *************************** }
  190. end;
  191.  
  192. function  TSeqAccount.balance(const mySeq: DrBob42_i.IntSeq): Single;
  193. begin
  194.   Result := 0;
  195.   { *************************** }
  196.   { *** User code goes here *** }
  197.   { *************************** }
  198. end;
  199.  
  200.  
  201. initialization
  202.  
  203.  
  204. end.