Presentation is loading. Please wait.

Presentation is loading. Please wait.

structured statically typed imperative wide-spectrum object-oriented high-level computer programming language extended from Pascal and other languages.

Similar presentations


Presentation on theme: "structured statically typed imperative wide-spectrum object-oriented high-level computer programming language extended from Pascal and other languages."— Presentation transcript:

1

2 structured statically typed imperative wide-spectrum object-oriented high-level computer programming language extended from Pascal and other languages the current version (known as Ada 2005) is defined by joint ISO/ANSI standard (ISO-8652:1995)

3 Notable features of Ada strong typing modularity mechanisms (packages) run-time checking parallel processing(tasks) exception handling Generics Ada 95 added support for object-oriented programming, including dynamic dispatch.

4 Output:Hello World

5 Selection if statement *Only if statement if Count = 3 then --If 3 print Put(“number is three"); New_Line; end if; *Nested if statement and else & else if statement if Count = 3 then Put("Count is 3"); New_Line; elsif Count = 5 then Put("Count is 5"); New_Line; else if Count = 4 then Put("Count is 4"); New_Line; else Put("Count is not 3 or 4"); New_Line; end if;

6 Repetition Statement *while statement while Count > 0 loop --loop while greater than 0 -- Repeated statements end loop; *for Statement for Count in 1.. 10 loop --count declared here Put( Integer'Image( Count ) ); end loop;

7 Continue repetition *in reverse key word in for for Count in reverse 1.. 10 loop Put( Integer'Image( Count ) ); end loop; *loop statement(for break in loop) loop Put( Count ); exit when Count = Count To; --Exit loop when... Count := Count + 1; end loop;

8 Variable names end comments *A variable name must start with a letter and can then be followed by any number of letters and digits and the underscore character. However, two underscore characters cannot occur next to each other and an underscore character must not start or finish a variable name. *comment with two – characters.Example; -- This program writes the message -- "Hello World" to a users terminal

9 Multiple selection case Ch := 'a'; --ch character variable case Ch is when '0' | '1' | '2' | '3' | '4' |'5' | '6' | '7' | '8' | '9' => Put("Character is a digit"); when 'A'.. 'Z' => Put("Character is upper case English letter"); when 'a'.. 'z' => Put("Character is lower case English letter"); when others => Put("Not an English letter or digit"); end case;

10 Input and output Put(variable name | string) print smth on screen.it is a function in Standart Ada.Text_Io. Get(variable name) read data from standart input and assign data to variable which is parameter of get functions. Like “put” function in Standart Ada.Text_Io

11 types *You can decleare new type in ada like this; type Distance is range 0.. 250_000; *ada allow type conversion between compatible type. variable name1:= variable type(con. Variable name) * constant declerations variable name: constant variable type:=value Type safety in ada(errors in a program can be detected at compile-time) type Miles is digits 8 range 0.0.. 25_000.0; type Kilometres is digits 8 range 0.0.. 50_000.0;

12 Continue type *subtype in ada type Speed_Mph is range 0.. 25_000; subtype Train_Speed is Speed_Mph range 0.. 130; *enumerations type Colour is (Red,B Using enumerations... Car_Colour : Colour; begin Car_Colour := Blue; case Car_Colour is when Red => Put("A red car"); New_Line; when Blue => Put("A blue car"); New_Line; when Green => Put("A green car"); New_Line; end case; …..

13 operators *many operators same in c++.Not same operators and new operators “/=“  not equal operator “**”  Exponentiation operator(a**4) “mod”  Modulus “rem”  Remainder “abs”  Returns the absolute value “not”  not operator “in”  is a member of (not in;is not member) Ch in 'A'.. 'Z‘ “:=“  assigment operator “=“  equal operator “and,or,xor”  bitwise operators

14 Functions in ada call function in procedure or function Put( Float( M_To_K_Fun( No_Miles ) ), Aft=>2, Exp=>0 ); Note:Aft parameters mean that two precision print and no miles variable in Mile type

15 Procedures in ada

16 Function and prodecure

17 Continue Function and prodecure *diffirent number parameter can sent function function Max2( A,B:in Integer ) return Integer is *Default parameters procedure Answer_Is( N:in Integer;Message:in Boolean := True ) is function call like this Answer_Is( 27 ); Answer_Is( 27, True ); -- By position Answer_Is( 27, Message => False ); -- By name

18 Packages as classes

19 Clauses with and use l with Ada.Text_Io; Make available to the unit all the public components of the package. However, when components of the package are used in a program they must be prefixed with the package name. l use Ada.Text_Io; Permit public components of the package to be used without having to prefix their name with that of the package name.

20 The record structure

21 Nested record structures

22 Arrays

23 Attributes of an array

24 Multidimensional arrays

25 Initializing an array

26 Continue arrays String type is a predefined type. type String is array ( Positive range <> ) of Character;. Unconstrained arrays type Numbers_Array is array ( Positive range <> ) of Integer; Computers_In_In_Room :Numbers_Array(513..519) := (2,2,2,3,2,1,3);. Slices of an array Computers_In_Rooms( 517.. 519 ).example; Put("Computers in rooms 517, 518 and 519 is: " ); Put( Sum( Computers_In_In_Room( 517.. 519 ) ) ); New_Line;

27 Inheritance

28 Header of base/Super class

29 Header of derived/Sub class

30 Visibility rules (Normal inheritance)

31 Define Abstract class

32 Defining new operators

33 Overloaded operators for bounded string class

34 Exceptions

35 Exception continue

36 Generics

37 Generic stack class header

38 Inheriting from a generic class

39


Download ppt "structured statically typed imperative wide-spectrum object-oriented high-level computer programming language extended from Pascal and other languages."

Similar presentations


Ads by Google