1 / 9

System Structures

System Structures. Package Abstract Data Type. Package. Essential programming tools 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. Encapsulation.

gerda
Télécharger la présentation

System Structures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. System Structures Package Abstract Data Type

  2. Package • Essential programming tools • 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 • Grouping a set of related entities in a well-defined module, with a clearly specified interface to other program • 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) • 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;

More Related