Download presentation
Presentation is loading. Please wait.
Published byAdrian Short Modified over 9 years ago
1
System Structures b Package b Abstract Data Type
2
Package b Essential programming tools b To develop a set of related operations and other entities, especially types, to test these thoroughly, and then to store them in an Ada program library for future use
3
Encapsulation b Grouping a set of related entities in a well- defined module, with a clearly specified interface to other program b The way, we produce software components that are pre-developed and pre-tested for reusability within an organization or distribution in the wider world
4
Abstract Data Type (ADT) b A special kind of package that groups a type together with a complete set of operations for that type
5
Example of ADT - - Partial Specification of Package Ada.Calendar PACKAGE Ada.Calendar IS - - Standard Ada package for dates and times Type Time IS Private; SUBTYPE Year_Number IS Integer Range 1901..2099; SUBTYPE Month_Number IS Integer Range 1..12; SUBTYPE Day_Number IS Integer Range 1..31;
6
- - functions to get the current time - - and return its date components FUNCTION Clock RETURN Time; FUNCTION Year (Date: Time) RETURN Year_Number; FUNCTION Month (Date: Time) RETURN Month_Number; FUNCTION Day (Date: Time) RETURN Day_Number; END Ada. Calendar;
7
Displaying Today’s Date
8
Example Program With Ada.Text_IO; With Ada.Calendar; With Ada.Integer_Text_IO; Procedure Todays_Date IS -- -- Finds and Dislay Today’s Date -- RightNow : Ada.Calendar.Time; ---current time ThisYear : Ada.Calendar.Year_Number; --current year ThisMonth: Ada.Calendar.Month_Number; --current year ThisDay : Ada.Calendar.Day_Number; --current year
9
Begin RightNow := Ada.Calendar.Clock; ThisYear := Ada.Calendar.Year(Date => RightNow ); ThisMonth := Ada.Calendar.Month(Date => RightNow ); ThisDay := Ada.Calendar.Day(Date => RightNow ); Ada.Text_IO.Put (Item => "Today's Date is "); Ada.Integer_Text_IO.Put (Item => ThisMonth, Width => 1); Ada.Text_IO.Put (Item => '/'); Ada.Integer_Text_IO.Put (Item => ThisDay, Width => 1); Ada.Text_IO.Put (Item => '/'); Ada.Integer_Text_IO.Put (Item => ThisYear, Width => 1); Ada.Text_IO.New_Line; End Todays_Date;
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.