Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 30 additions & 17 deletions courses/fundamentals_of_ada/273_subprogram_contracts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -528,35 +528,48 @@ Quiz

.. code:: Ada

type Index_T is range 1 .. 100;
-- Database initialized such that value for element at I = I
Database : array (Index_T) of Integer;
-- Set the value for element Index to Value and
-- then increment Index by 1
function Set_And_Move (Value : Integer;
Database : String (1 .. 10) := "ABCDEFGHIJ";
-- Set the value for the element at position Index in
-- array Database to Value and then increment Index by 1
function Set_And_Move (Value : Character;
Index : in out Index_T)
return Boolean
with Post => ...

Given the following expressions, what is their value if they are evaluated in the postcondition
of the call :ada:`Set_And_Move (-1, 10)`
of the call :ada:`Set_And_Move ('X', 4)`?

.. list-table::
.. container:: animate 2-

.. image:: subprogram_contracts_special_attributes-legend.svg
:width: 60%

.. container:: animate 1-

* ``Database'Old (Index)``

.. container:: animate 2-

.. image:: subprogram_contracts_special_attributes-answer1.svg
:width: 60%

.. container:: animate 1-

* ``Database (Index'Old)``

* - ``Database'Old (Index)``
.. container:: animate 3-

- :animate:`11`
- :animate:`Use new index in copy of original Database`
.. image:: subprogram_contracts_special_attributes-answer2.svg
:width: 60%

* - ``Database (Index'Old)``
.. container:: animate 1-

- :animate:`-1`
- :animate:`Use copy of original index in current Database`
* ``Database (Index)'Old``

* - ``Database (Index)'Old``
.. container:: animate 4-

- :animate:`10`
- :animate:`Evaluation of Database (Index) before call`
.. image:: subprogram_contracts_special_attributes-answer3.svg
:width: 60%

-------------------------------------
Stack Example (Spec with Contracts)
Expand Down
99 changes: 99 additions & 0 deletions images/subprogram_contracts_special_attributes-answer1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
97 changes: 97 additions & 0 deletions images/subprogram_contracts_special_attributes-answer2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
95 changes: 95 additions & 0 deletions images/subprogram_contracts_special_attributes-answer3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading