-- Code of Figure 5.22, pages 156-157 from
-- Kenneth C. Louden, Programming Languages
-- Principles and Practice 2nd Edition
-- Copyright (C) Brooks-Cole/ITP, 2003

with Text_IO; use Text_IO;
with Ada.Integer_Text_IO;
use Ada.Integer_Text_IO;
with Ada.Float_Text_IO;
use Ada.Float_Text_IO;

procedure opover is

type IntDouble is 
record 
  i: Integer;
  d: Float;
end record;

function "<" (x,y: IntDouble) return Boolean is
begin
  return x.i < y.i and x.d < y.d;
end "<";

function "+" (x,y: IntDouble) return IntDouble is
z: IntDouble;
begin
   z.i := x.i + y.i;
   z.d := x.d + y.d;
   return z;
end "+";

x, y: IntDouble;

begin
  x := (1,2.1);
  y := (5,3.4);
  if (x < y) then x := x + y;
  else y := x + y;
  end if;
  put(x.i); put(" "); put(x.d); new_line;
end opover;

