comp.lang.ada
 help / color / mirror / Atom feed
* Implementing linked attributes in ada
@ 2005-08-22  8:21 ramesh
  2005-08-22 19:14 ` Simon Wright
  0 siblings, 1 reply; 3+ messages in thread
From: ramesh @ 2005-08-22  8:21 UTC (permalink / raw)


Hi Im trying to understand linked attributes in ada, can anybody can
help me by sending relevant notes or links to study along with some
sample programs??

my program has two records department and faculty, i have created a
link attribute between them called Hire_data with attributes title and
salary. In my program i need to have the folowing condition fulfilled,
a department can hire atmost 10 faculty n a faculty can work no more
than 2 departments.

here is the specification i wrote
actually this a part of my whole project

with Ada.Text_IO; use Ada.Text_IO;
with combined; use combined;
with date_pack; use date_pack;
package optionb is
type Name1 is (None, JiahuangJi, KathrynWilliams, GeorgeBush,
RoanldReagan, BillClinton, DavidBurris, PeterCooper, GarySmith,
GracielaGonzalez, KenHeartness,  LarryJones);
type sex1 is (male, female);
type Dept_Names is (None,COmputerScience, Biology);
type Majors is (None,ComputerScience, Math, Business, Physics, Biology,
Chemistry);

Package Name_IO is new Ada.Text_IO.Enumeration_IO(Name1); use Name_IO;
package Sex_IO is new Ada.Text_IO.Enumeration_IO(Sex1); use Sex_IO;
package Majors_IO is new Ada.Text_IO.Enumeration_IO(Majors); use
Majors_Io;
package Dept_Names_IO is new Ada.Text_IO.Enumeration_IO(Dept_Names);
use Dept_Names_IO;
package Int_IO is new Integer_IO(Integer); use Int_IO;

type Job_Title_Type is (None, Chair, Professor, AssistantProfessor,
Lecturer);
package Job_IO is new Ada.Text_IO.Enumeration_IO(Job_Title_Type);
procedure put(Item: Job_Title_Type; Width: in Ada.Text_IO.Field :=
Job_IO.Default_Width; Set: in Ada.Text_IO.Type_Set:=
Job_IO.Default_Setting)  renames Job_IO.put;

type Money is delta 0.01 range 0.00..100.00;
package Money_IO is new Ada.Text_IO.Fixed_IO(Money);
procedure put(Item: in Money; Default_Fore: Ada.Text_IO.Field := 4;
Default_Aft:  Ada.Text_IO.Field := 2; Default_Exp:  Ada.Text_IO.Field
:=0) renames Money_IO.put;

type Hire_data_type;
type Hire_Data_ptr is access Hire_Data_type;
type Hire_Data_ptr_Array is array (1..2) of Hire_Data_ptr;
type Faculty is new Employee with
record
name : Name1;
Birthday : Date;
sex: sex1;
MajorField : Majors:=None;
DeptEmbed : Department;
--Dept_Emp_Array : DeptArray;
NumDeptEmp : integer := 0;
Dept_pt : Hire_Data_ptr_Array;
end record;

type Faculty_Ptr is access all Faculty'Class;

type Hire_data_Type is record
JOb_title : Job_Title_Type := none;
Salary : Money := 0.00;
Faculty_p : Faculty_ptr;
Department_p : Dept_ptr;
end record;



procedure put(aFaculty: Faculty_Ptr);
type Hire_Data_ptrArray is array(1..10) of Hire_data_ptr;

type Department is new College with record
Dept_Name : Dept_Names;
FacultyEmp_Array : Fac_Array;
NumFacEmp : Integer:= 0;
staffEmp_Array : Staff_Array;
NumStaffEmp : integer:=0;
Faculty_pt : Hire_Data_ptrArray;
end record;

type Dept_Ptr is access all Department'Class;
procedure put(aDepartment: Dept_ptr);
procedure put_Faculty(aDepartment: Dept_Ptr);


procedure Hire(aDepartment : in out Dept_ptr; aFaculty : in out
Faculty_ptr; aHire : in out Hire_Data_ptr; aTitle : in
Job_Title_Type;aSalary: Money);
end optionb;


I need hlp in writing the body to fulfill my condition.


I also need to have another linked attribute "rating" for faculty
record. 

waiting for ur help.....




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Implementing linked attributes in ada
  2005-08-22  8:21 Implementing linked attributes in ada ramesh
@ 2005-08-22 19:14 ` Simon Wright
  2005-08-24 21:22   ` Simon Wright
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Wright @ 2005-08-22 19:14 UTC (permalink / raw)


It's very hard to see the wood for the trees in this spec! and I'm not
in a position to do your homework for you (apologies if it isn't
homework ...).

One thing I will say is that if I were setting this problem I would
have in mind to change the limits (10 faculty per department, can't
work in more than one department). These are arbitrary rules and not
part of the structure of the problem, I think your specs should
reflect structure.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Implementing linked attributes in ada
  2005-08-22 19:14 ` Simon Wright
@ 2005-08-24 21:22   ` Simon Wright
  0 siblings, 0 replies; 3+ messages in thread
From: Simon Wright @ 2005-08-24 21:22 UTC (permalink / raw)


Simon Wright <simon@pushface.org> writes:

> One thing I will say is that if I were setting this problem I would
> have in mind to change the limits (10 faculty per department, can't
> work in more than one department).

Sorry, that was 2 departments, wasn't it!



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-08-24 21:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-22  8:21 Implementing linked attributes in ada ramesh
2005-08-22 19:14 ` Simon Wright
2005-08-24 21:22   ` Simon Wright

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox