Yurttas/PL/IL/Ada-95/F/04/02/00/class account.adb
Jump to navigation
Jump to search
1--
2-- Copyright(C) 1998
3-- All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
4--
5-- Permission to use, copy, modify, and distribute this
6-- software and its documentation for EDUCATIONAL purposes
7-- and without fee is hereby granted provided that this
8-- copyright notice appears in all copies.
9--
10
11-- date : September 1, 1999.
12-- author : Salih Yurttas.
13-- adapted from John English's book.
14
15-- class_account.adb
16
17
18with Ada.Text_IO;
19use Ada.Text_IO;
20
21package body Class_Account is
22
23 procedure Statement(The:in Account) is
24 package Flo_IO is new Float_IO(Money);
25 use Flo_IO;
26 begin
27 Put("Mini statement: The Amount on deposit is $");
28 Put(The.Balance_Of, Aft=>2, Exp=>0);
29 New_Line(2);
30 end statement;
31
32 procedure Deposit(The : in out Account;
33 Amount : in PMoney) is
34 begin
35 The.Balance_Of := The.Balance_Of + Amount;
36 end Deposit;
37
38 procedure Withdraw(The : in out Account;
39 Amount : in PMoney;
40 Get : out PMoney) is
41 begin
42 if The.Balance_Of >= Amount Then
43 The.Balance_Of := The.Balance_Of - Amount;
44 Get := Amount;
45 else
46 Get := 0.00;
47 end if;
48 end Withdraw;
49
50 function Balance(The : in Account) return Money is
51 begin
52 return The.Balance_Of;
53 end Balance;
54
55end Class_Account;