comp.lang.ada
 help / color / mirror / Atom feed
* need help with errors im getting
@ 2005-06-24 21:59 ramesh
  2005-06-24 22:42 ` Ed Falis
  2005-06-25  6:17 ` Jeffrey Carter
  0 siblings, 2 replies; 10+ messages in thread
From: ramesh @ 2005-06-24 21:59 UTC (permalink / raw)


Hi Im a biginner in Ada, I get the following errors for the following
code.


with oosum1pro; use oosum1pro;---for date
with oosum1pro1; use oosum1pro1;

package Student_pack is

type Majors is (ComputerScience, Math, Business, Physics, Biology,
Chemistry);
type Classify is (Freshman, Sophomore, Junior, Senior, GradStudent);
--type Hobbies is (None, SailBoarding, Swimming, Hiking, Marbles,
SkyDiving, Acting);
--subtype String5 is String(1..5);
--type Sex1 is (female,male);

type Student is private;

task Studenttask is

entry Student(n: String5; dob: Date; s : Sex1; maj : Majors; cl :
Classify; ed : Date);
entry PrintName(name: Student);--line 17
entry PrintMajor(major: Student);
entry SetMajor(major1: Student);
entry SetClasification(cl: Student);
entry PrintClassification(cl: Student);
entry PrintAll(s: Student);--line 22

end studenttask;

private

type Student is new person with--line 28
record
Major : Majors;
Classification: Classify;
EntryDate: Date;
end record;

end Student_pack;


Errors are at
At line 17,18,19,20,21,22
"subtype mark required in this context"
At line 28

COmpletion of nonlimited type cannot be limited.




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

* Re: need help with errors im getting
  2005-06-24 21:59 need help with errors im getting ramesh
@ 2005-06-24 22:42 ` Ed Falis
  2005-06-25  1:43   ` ramesh
  2005-06-25  6:17 ` Jeffrey Carter
  1 sibling, 1 reply; 10+ messages in thread
From: Ed Falis @ 2005-06-24 22:42 UTC (permalink / raw)


Looks like the declaration of entry Student is hiding the type Student.   
Try using Student_Pack.Student in each of the places you got the error.



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

* Re: need help with errors im getting
  2005-06-24 22:42 ` Ed Falis
@ 2005-06-25  1:43   ` ramesh
  0 siblings, 0 replies; 10+ messages in thread
From: ramesh @ 2005-06-25  1:43 UTC (permalink / raw)


Hi Ed Falis,

Thank you for the help, it worked for the errors from 17 through 22,
but was not able to get rid of the error on line 28. when i give
Student_pack.student here it gives an error "missing is"when i give
here as Student it gives an error "completion of nonlimited type cannot
be limited". Actually here the Person is an abstract tagged type.
Waiting for you reply,
Thank you again,


Ed Falis wrote:
> Looks like the declaration of entry Student is hiding the type Student.
> Try using Student_Pack.Student in each of the places you got the error.




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

* Re: need help with errors im getting
  2005-06-24 21:59 need help with errors im getting ramesh
  2005-06-24 22:42 ` Ed Falis
@ 2005-06-25  6:17 ` Jeffrey Carter
  2005-06-25 18:38   ` ramesh
  1 sibling, 1 reply; 10+ messages in thread
From: Jeffrey Carter @ 2005-06-25  6:17 UTC (permalink / raw)


ramesh wrote:
> type Student is new person with--line 28

> At line 28
> 
> COmpletion of nonlimited type cannot be limited.

We could help you better if you included the specs of the packages in 
the context clause.

Apparently type Person is a limited type. The public view of type 
Student is not limited, so this is not allowed. Either Student must be 
limited, or Person must not.

-- 
Jeff Carter
"No one is to stone anyone until I blow this whistle,
do you understand? Even--and I want to make this
absolutely clear--even if they do say, 'Jehovah.'"
Monty Python's Life of Brian
74



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

* Re: need help with errors im getting
  2005-06-25  6:17 ` Jeffrey Carter
@ 2005-06-25 18:38   ` ramesh
       [not found]     ` <fovrb1t2l3nvsq6qden8vf2fkmgvg3614h@4ax.com>
  0 siblings, 1 reply; 10+ messages in thread
From: ramesh @ 2005-06-25 18:38 UTC (permalink / raw)


Thank you jeff and Denis for your time to look at my code.
Here is the specification on which Im working right now.

Person -->	Employee, Student, Citizen

Here Person and Employee should be meta classes, and Employee, Student,
Citizen must inherit from Person.

Employee--->Faculty, Staff

The specification team is not currently able to supply the desired
level of detail.  However, based on the available information, the
design team has made the following decisions.  You may make reasonable
modifications to method parameter lists.  You may also add additional
data structures too class definitions.

Person		Employee		               Date
Name                        DateHired: Date;
Month
Birthday: Date;           Employee(n,dob,s,dh)               Day
Sex                           PrintDateHired()
Year
Person(n,dob, s)
PrintName()				Date()

        Date(mm,dd,yy)

        SetDate(mm, dd, yy)

         PrintDate()


"Person" and "Employee" must be implemented as abstract (meta
or virtual) classes!  Note that Birthday and DateHired are imbedded,
not inherited.  Months are to take on the values January through
December.  The year field may only take on values from 1800 through
2050.  Your code must enforce these abstractions at runtime.  The day
field must similarly be restricted to the values 1 through 31 (enforced
at runtime).  It is desirable to have two methods for creating dates:
first a method which initializes the date to specified values at the
time the date is created, and secondly a method that creates a date and
initializes it to the default value January 1, 1970.  Actually,
management would be impressed if the default is obtained from the
computer's clock.  If you implement this option, mark the code
clearly with a high lighter.  The method SetDate may be used to change
the current date.  Sex should be restricted to the values "male"
and "female."

If you implement faculty, staff, students, and citizens as tasks, their
body should consist of a loop where they wait for a call to any method.
 Respond to the method when called.  Every T seconds, they should
experience a time out where they state something of great importance
prior to resumption of waiting, e.g., "task named XXX is bored."

-------------------------------
Student	class
Major
Classification
EntryDate
Student(n, dob, s, maj, cl, ed)
PrintName()
PrintMajor()
SetMajor()
SetClassification()
PrintClassification()
PrintAll()
-------------------------------------------------------

Citizen	class
Hobby
Citizen(n, dob, s)
Citizen(n, dob, s, hobbyName)
Citizen(n, dob, s, hobbyName, doh)
PrintName()
SetHobby()
PrintHobby()
PrintAll()

Allowable majors include: Computer Science, Math, Business, Physics,
Biology, and Chemistry.
Classification may take on the values: Freshman, Sophomore, Junior,
Senior, and GradStudent.
The EntryDate for students is the date they first registered for
school.
Allowable hobbies include sail boarding, swimming, hiking, marbles, sky
diving, acting, and none.  If a hobby is not specified, the value of
Hobby should default to "none" and the date the hobby started to
January 1, 1970.  Date objects
---------------------------------------------------------
Faculty class
MajorField
Faculty(n, dob, s, hd, mf)
PrintName()
PrintHireDate()
PrintMajorField()
PrintAll()
------------------------------------------------------------


Staff  class

Hobby
DateOfHobby // date the hobby started
Staff(n, dob, s, hd, hobbyName, doh)
PrintName()
SetHobby()
PrintHobby()
PrintAll()

---------------------------------------------------------------------
Date class
Month
Day
Year
CreateADate()
CreateADate(M,D,Y)
SetDate(M,D,Y)
GetDate()
GetMonth()
GetDay()
GetYear()

Date should be implemented using embedding, not inheritance.  You must
be able to create a date supplying the month, day, and year.  You must
also be able to create a date with it defaulting to January 1, 1970.
Days should be constrained to the range 1 through 31 and years to the
range 1940 through 2020.




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

* Re: need help with errors im getting
       [not found]       ` <6g5sb1ptj1611oq6vbiirutlj9gv5lv39m@4ax.com>
@ 2005-06-26  8:12         ` ramesh
  2005-06-26  9:23           ` ramesh
       [not found]           ` <fu9ub1la6ofoc361j6pec48je2efh0b9e9@4ax.com>
  0 siblings, 2 replies; 10+ messages in thread
From: ramesh @ 2005-06-26  8:12 UTC (permalink / raw)


Thanks Dennis for you time and valuable sujjestions.

I have changed my code now but having error in one of the procedures to
get Employee Hired date.
-------------------------------------------------------------
Testing.Ads
-------------------------------------------------------------
with Date_pack; use Date_pack;

package testing is


type sex1 is (male, female);
subtype String20 is String(1..20);

type person is abstract tagged limited private;
procedure PersonDetails(p: in out Person ; name1: String20; dob: Date;
s: sex1);
procedure printName(person_name: Person);

type Employee is abstract tagged limited private;
procedure EmployeeDetails(e: in out Employee; name2: String20;
dob:Date; s: sex1);
procedure printDateHired(dh: Employee);

private
Year, Day : INTEGER;
MOnth : Month_name;

type person is abstract tagged limited

record
Name : String20;
BirthDate : Date := (January,1,1970);
Sex : Sex1;
end record;
---------------------------------------------------------------
Testing.Adb
--------------------------------------------------------------
with Ada.Text_IO; use Ada.Text_IO;
with Date_pack; use Date_pack;
--with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

--with testing; use testing;

package body testing is

procedure PersonDetails( p: in out Person;name1: String20; dob: Date;
s: sex1) is

begin
p.name := name1;
p.sex := s;
p.BirthDate:= dob;
end;

procedure printName(person_name: Person) is

begin
for i in 1..String20'Last loop
put(Person_name.name(i));
end loop;
end;

procedure EmployeeDetails(e: in out Employee; name2: String20;
dob:Date; s: sex1) is
begin
e.name := name2;
e.sex := s;
e.BirthDate := dob;
end;

procedure printDateHired(dh : Employee) is
begin
put(dh.DateHired);----- Getting error here"invalid parameter list in
call"
--put(dh);
--Put(Month,10);Put("/"); Put(Day,3);Put("/"); Put(Year,5);

end;

end testing;
------------------------------------------------------------
Error: "Invalid Parameter list in call" --marked as seen above  for
line
--------------------------------------------------------------------


If you wanna look at Date_pack

Date_pack.Ads
---------------------------------------------

package Date_pack is

type Month_name is (January, February, March, April, May, June, July,
August, September, October, November, December);
--subtype month_name is integer range 1..12;--to change it into
Jan,feb,mar,... refer page 51 of AdaTagged1.doc
subtype day_range is integer range 1..31;
subtype year_range is integer range 1800..2050;

type Date is

record
month: month_name;
day: day_range;--Integer range 1..31;
year: year_range;--Integer range 1800..2050;
end record;

procedure CreateADate;
procedure CreateADate(d: in out Date; mm : month_name; dd : day_range;
yy : year_range);
procedure SetDate(d: in out Date; mm : month_name; dd : day_range; yy :
year_range);
Procedure GetDate(d: in out Date);
procedure GetMonth(d: in out Date);
procedure GetDay(d: in out Date);
procedure GetYear(d: in out Date);

end Date_pack;

---------------------------------------------------------------
Im still working on Student package as i wanted to do using tasks,
Please help with it.
--------------------------------------------------------




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

* Re: need help with errors im getting
  2005-06-26  8:12         ` ramesh
@ 2005-06-26  9:23           ` ramesh
       [not found]           ` <fu9ub1la6ofoc361j6pec48je2efh0b9e9@4ax.com>
  1 sibling, 0 replies; 10+ messages in thread
From: ramesh @ 2005-06-26  9:23 UTC (permalink / raw)


----------------------------------------------------------
Student_pack.ads
----------------------------------------------------


with testing; use testing;
with Date_pack; use Date_pack;

package Student_pack is

type Majors is (ComputerScience, Math, Business, Physics, Biology,
Chemistry);
type Classify is (Freshman, Sophomore, Junior, Senior, GradStudent);

type Student is limited private;

--type Access_Person(obj: access Person'Class) is--- is new Person with
--record
--Major : majors;
--Classification: Classify;
--EntryDate: Date;
--end record;

task Studenttask is

entry Student(n: String20; dob: Date; s : Sex1; maj : Majors; cl :
Classify; ed : Date);
entry PrintName(name: Student_pack.Student);
entry PrintMajor(major: Student_pack.Student);
entry SetMajor(major: Student_pack.Student);
entry SetClassification(cl: Student_pack.Student);
entry PrintClassification(cl: Student_pack.Student);
entry PrintAll(s: Student_pack.Student);

end studenttask;

private

type Student is new person with

record
Major : Majors;
Classification: Classify;
EntryDate: Date;
end record;
--type C is tagged limited record A : AC (C'Access); B : BC (C'Access);
... -- other stuff if desired end record;
--type Student is tagged limited record Person :
Access_Student(Student'class); end record;


end Student_pack;

------------------------------------------------------
Student.Adb
_------------------------------------------------------


with testing; use testing;
with Date_pack; use Date_pack;

package Student_pack is

type Majors is (ComputerScience, Math, Business, Physics, Biology,
Chemistry);
type Classify is (Freshman, Sophomore, Junior, Senior, GradStudent);

type Student is limited private;

--type Access_Person(obj: access Person'Class) is--- is new Person with
--record
--Major : majors;
--Classification: Classify;
--EntryDate: Date;
--end record;

task Studenttask is

entry Student(n: String20; dob: Date; s : Sex1; maj : Majors; cl :
Classify; ed : Date);
entry PrintName(name: Student_pack.Student);
entry PrintMajor(major: Student_pack.Student);
entry SetMajor(major: Student_pack.Student);
entry SetClassification(cl: Student_pack.Student);
entry PrintClassification(cl: Student_pack.Student);
entry PrintAll(s: Student_pack.Student);

end studenttask;

private

type Student is new person with

record
Major : Majors;
Classification: Classify;
EntryDate: Date;
end record;
--type C is tagged limited record A : AC (C'Access); B : BC (C'Access);
... -- other stuff if desired end record;
--type Student is tagged limited record Person :
Access_Student(Student'class); end record;


end Student_pack;
----------------------------------------------------------------
Im getting errors in the body of Student_pack:

Its not allowing the inherited fields name, sex, BirthDAte, evn its not
recognising the student fields: major, classification, entrydate,

Please help me with this im really struggling, do i need to create a
pointer to point to store student and person  details.




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

* Re: need help with errors im getting
       [not found]             ` <l3eub1l2ru5pguun3kitesfmgnfngur7vp@4ax.com>
@ 2005-07-02  8:14               ` ramesh
  2005-07-04  5:38               ` Dave Thompson
  1 sibling, 0 replies; 10+ messages in thread
From: ramesh @ 2005-07-02  8:14 UTC (permalink / raw)


Hi

I need some help again, I finished with my recent types,
person,employee,student,citizen,faculty,staff.

now i have to add a university, college and department to be associated
to it.

The University has following fields:

name, Datefounded, collegeArray:array(1..4) of college_ptr; numcollege
:integer;
it has following methods
University(un,df)
printName()
InsertCollege(collpt)
printDateFOunded()
PrintAll() ------ should list all information abt university
including names of colleges.

I have got all methods in it excecpt in PrintAll() i m not able to
access colleges, i mean names of colleges associated with univ to
print.
i have got doubt abt Insert college also.


procedure InsertCollege(u: in out Univ_ptr; c: in out College_ptr; un:
Univ_Name1; df : Date; c1: College_Name) is--;c1: in out College_ptr)
is
begin
for i in 1..4 loop
u.Col_Array(i) := new College;
c.Name := un;
c.DateFounded := df;
c.Col_Name:= c1;
end loop
end InsertCollege;


------comment on above code if its correct and make necessary changes.
the doubt i have with it is when only one college details are passed to
it why i need a loop if i remove it the prob is when a second college
needs to be inserted in the array how to increment the value of i,
should i have explictly mention Col_array(1) Col_array(2) .... when a
new college is created.

The main prob is with my PrintAll()

in accesing the college names from college array
The code i wrote is
procedure PrintAll(u: Univ_ptr)is
temp: college_Array;
begin
new_line;
Put(" University Name : ");
put (u.Name);
new_line;
put(" The University was founded on : ");
put(u.DateFounded);
new_line;
put("******************************************");
new_line;
put("The colleges in the university are: ");
new_line;

put(u.Col_Array(1).Col_name);

--for i in 1..4 loop
--put(Col_Array(i).Col_Name);
--end loop;

--for i in 1..u.Col_Array'Last loop
--put(u.Col_Array(i.all));
--new_line;
--end loop;
end PrintAll;

it compiles but gives a constraint error when trying to print college
names

I can send the entire code if needed.




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

* Re: need help with errors im getting
       [not found]             ` <l3eub1l2ru5pguun3kitesfmgnfngur7vp@4ax.com>
  2005-07-02  8:14               ` ramesh
@ 2005-07-04  5:38               ` Dave Thompson
  2005-07-04 21:16                 ` ramesh
  1 sibling, 1 reply; 10+ messages in thread
From: Dave Thompson @ 2005-07-04  5:38 UTC (permalink / raw)


On Sun, 26 Jun 2005 23:33:11 GMT, Dennis Lee Bieber
<wlfraed@ix.netcom.com> wrote:
<snip>
>          when February =>
>             if (Y mod 4) = 0 and (Y mod 400) /= 0 then
>                if D > 29 then

mod 4 except not mod 100 except YES mod 400
Either (@4= and @100/= ) or @400= 
or @4=  and (@100/= or @400= ) works.

For years 1940 .. 2020 which you noted earlier was one version of the
OP's spec, or up to 1901 .. 2099, @4= is enough. Of course, this is
the same line of thinking that gave us Y2K. At least in Ada any such
decisions can and should be selfdocumented and easy to find -- if not
necessarily to fix/change.

- David.Thompson1 at worldnet.att.net



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

* Re: need help with errors im getting
  2005-07-04  5:38               ` Dave Thompson
@ 2005-07-04 21:16                 ` ramesh
  0 siblings, 0 replies; 10+ messages in thread
From: ramesh @ 2005-07-04 21:16 UTC (permalink / raw)


Hi can anybody help me with the linked attributes part, I have to
create a link attribute between Department and Faculty which has
Faculty's Title and salary.

Titles: Chair, Professor, Assistant Professor, Lecturer.

A department can have atmost 10 Faculty. A Faculty can work for no more
than 2 departments.

The Faculty has one more linked attribute of Faculty's Rating. The
chair is responsible for the rating.
chair(0..1) and Prof(0..9)

According to me the relation between Department and Faculty is m:n,
and relation between chair and prof is 1:m, i have no idea how to
acheive this.
i wrote a code right now for 1:1 relation ship

specification:

type Hire_data_type;
type Hire_Data_pointer is access Hire_Data_type;

type Hire_data_Type is record
JOb_title : JOb_Title_Type := none;
Salary : Money := 0.00;
Faculty_p : Faculty_ptr;
end record;

Body:

procedure Hire(aDepartment : in out Dept_ptr; aFaculty : in out
Faculty_ptr; aHire : in out Hire_Data_pointer; aTitle : in
Job_Title_Type;aSalary: Money) is
Hire_Data_Pt: Hire_Data_Pointer;
begin
Hire_Data_Pt := new Hire_Data_Type;
aDepartment.Faculty_pt := Hire_Data_pt;
Hire_Data_pt.Faculty_p := aFaculty;
Hire_Data_pt.Job_Title := aTitle;
Hire_Data_pt.salary := aSalary;
end Hire;

Can anybody help me how to proceed with this.

Thanks.




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

end of thread, other threads:[~2005-07-04 21:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-24 21:59 need help with errors im getting ramesh
2005-06-24 22:42 ` Ed Falis
2005-06-25  1:43   ` ramesh
2005-06-25  6:17 ` Jeffrey Carter
2005-06-25 18:38   ` ramesh
     [not found]     ` <fovrb1t2l3nvsq6qden8vf2fkmgvg3614h@4ax.com>
     [not found]       ` <6g5sb1ptj1611oq6vbiirutlj9gv5lv39m@4ax.com>
2005-06-26  8:12         ` ramesh
2005-06-26  9:23           ` ramesh
     [not found]           ` <fu9ub1la6ofoc361j6pec48je2efh0b9e9@4ax.com>
     [not found]             ` <l3eub1l2ru5pguun3kitesfmgnfngur7vp@4ax.com>
2005-07-02  8:14               ` ramesh
2005-07-04  5:38               ` Dave Thompson
2005-07-04 21:16                 ` ramesh

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