generic
type INDEP_TYPE is digits <>;
type DEP_TYPE is digits <>;
type INDEX is (<>);
type INDEP_ARRAY is array (INDEX) of INDEP_TYPE;
type DEP_ARRAY is array (INDEX) of DEP_TYPE;
Package PlotFct is
procedure PLOT(INDEP_VAR : in INDEP_ARRAY;
DEP_VAR : in DEP_ARRAY);
End PlotFct;
with Ada.Text_Io;
package body PlotFct is
procedure PLOT(INDEP_VAR : in INDEP_ARRAY;
DEP_VAR : in DEP_ARRAY) is
-- prints my student header
procedure Print16 is
begin
Ada.Text_Io.New_Line;
Ada.Text_Io.Put("Course: CS450");
Ada.Text_Io.Put(" Name: Juan Velasquez NN: 16");
Ada.Text_Io.New_Line;
end Print16;
--package int_io is NEW Ada.Text_IO.Integer_IO(INDEX);
--package int_io is NEW Ada.Text_IO. (INDEX);
package REAL_IO is new Ada.Text_IO.FLOAT_IO(DEP_TYPE);
package ind_io is new Ada.Text_IO.Float_IO(INDEP_TYPE);
package dep_io is new Ada.Text_IO.Float_IO(DEP_TYPE);
it : INDEP_TYPE;
dt : DEP_TYPE;
ind : INDEX;
i : Integer;
begin
-- print my student header
Print16;
Ada.Text_Io.Put("Dependant Variable");
Ada.Text_Io.Put("f:");
--Ada.Text_Io.Put(INDEP_VAR(1));
DEP_TYPE.Put(DEP_VAR'VAL(1),1,2,0);
DEP_TYPE.Put(DEP_VAR'VAL(1),1,2,0);
DEP_TYPE.Put(DEP_VAR'POS(DEP_VAR'BASE'FIRST),1,2,1);
DEP_TYPE.Put(DEP_VAR'LARGE,1,2);
DEP_TYPE.Put(DEP_VAR'FIRST,1,2);
DEP_TYPE.Put(DEP_VAR'FIRST(1),1,2);
Ada.Text_Io.New_Line;
Ada.Text_Io.Put("l:");
--dep_io.Put(DEP_VAR'POS(DEP_VAR'BASE'FIRST),1,2,1);
--DEP_TYPE.Put(DEP_VAR'VAL(1),1,2,0);
Ada.Text_Io.New_Line;
--for i in DEP_VAR loop
-- dep_io.put(DEP_VAR(i), 3,2,0);
--end loop;
Ada.Text_Io.Put("IND. DEP.");
--for i in INDEP_VAR loop
-- dep_io.put(INDEP_VAR(i), 3,2,0);
--end loop;
end PLOT;
end PlotFct;
procedure TestHarness is
type Days is (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday);
type Msg is array (Monday..Sunday) of Float;
type Vog is array (Monday..Sunday) of Float;
package Plot1 is new PlotFct(INDEP_TYPE => Float,
DEP_TYPE => Float,
INDEX => Monday..Sunday,
INDEP_ARRAY => Msg,
DEP_ARRAY => Vog);
type AryRange is range 1..30;
type Indo is array (AryRange) of Float;
type Depo is array (AryRange) of Float;
package Plot2 is new PlotFct(INDEP_TYPE => Float,
DEP_TYPE => Float,
INDEX => AryRange,
INDEP_ARRAY => Indo,
DEP_ARRAY => Depo);
i : Integer;
a : Float;
b : Float;
begin
-- initlize arrays: Msg, and Vog
a := 0.0;
b := -5.3;
for i in Monday..Sunday loop
Msg(i) := ;
Vog(i) := ;
a := a + 0.5;
b := b + 0.2;
end loop;
Plot1.PLOT(Msg, Vog);
-- initlize arrays: Msg, and Vog
a := 5.0;
b := 7.3;
for i in AryRange loop
Msg(i) := ;
Vog(i) := ;
a := a + 0.1;
b := b + 0.7;
end loop;
Plot2.PLOT(Msg, Vog);
end TestHarness;