• Keine Ergebnisse gefunden

Exercise2BehaviouralSubtypingII Exercise1BehaviouralSubtypingI PracticeSheet10:FortgeschritteneAspekteobjektorientierterProgrammierung(SS2008)

N/A
N/A
Protected

Academic year: 2022

Aktie "Exercise2BehaviouralSubtypingII Exercise1BehaviouralSubtypingI PracticeSheet10:FortgeschritteneAspekteobjektorientierterProgrammierung(SS2008)"

Copied!
2
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Prof. Dr. A. Poetzsch-Heffter Dipl.-Inform. Markus Reitz

Technische Universität Kaiserslautern Fachbereich Informatik AG Softwaretechnik

Practice Sheet 10: Fortgeschrittene Aspekte objektorientierter Programmierung (SS 2008)

Date of Issue: 17. Juni 2008 Deadline: 23. Juni 2008 (until 10 a.m. as PDF via E-Mail)

Exercise 1 Behavioural Subtyping I

Check the following source code fragments with respect to violation or fulfillment of theBehavioural Subtypeproperty as introduced in the lecture. Explain the reason for violation or fulfillment.

p u b l i c c l a s s A {

/ /@ i n v a r i a n t v a l u e>=0;

p r o t e c t e d i n t v a l u e ;

/∗@

@ r e q u i r e s a>=0;

@∗/

p u b l i c v o i d s e t (i n t a ) { v a l u e=a ; }

/∗@

@ e n s u r e s \r e s u l t>=0;

@∗/

p u b l i c i n t g e t ( ) { r e t u r n v a l u e ; } }

p u b l i c c l a s s B e x t e n d s A {

/∗@

@ r e q u i r e s a>=10;

@∗/

p u b l i c v o i d s e t L a r g e (i n t a ) { v a l u e=a ; } }

p u b l i c c l a s s C { p r o t e c t e d i n t v a l u e ;

/∗@

@ r e q u i r e s a>0;

@∗/

p u b l i c v o i d s e t (i n t a ) { v a l u e=a ; }

/∗@

@ e n s u r e s \r e s u l t>0;

@∗/

p u b l i c i n t g e t ( ) { r e t u r n v a l u e ; } }

p u b l i c c l a s s D e x t e n d s C {

/∗@

@ a l s o

@ r e q u i r e s a>10;

@∗/

@ O v e r r i d e p u b l i c v o i d s e t (i n t a ) { v a l u e=a ; }

/∗@

@ a l s o

@ e n s u r e s \r e s u l t>10;

@∗/

@ O v e r r i d e p u b l i c i n t g e t ( ) { r e t u r n v a l u e ; } }

p u b l i c a b s t r a c t c l a s s E { / /@ p u b l i c m o d e l i n t c o u n t ;

/∗@

@ e n s u r e s c o u n t==0;

@∗/

p u b l i c a b s t r a c t v o i d r e s e t ( ) ;

/∗@

@ e n s u r e s c o u n t>\o l d ( c o u n t ) ;

@∗/

p u b l i c a b s t r a c t v o i d i n c r e m e n t ( ) ; }

p u b l i c c l a s s F e x t e n d s E {

/ /@ p r i v a t e r e p r e s e n t s c o u n t < v a l u e ; p r i v a t e i n t v a l u e ;

p u b l i c v o i d r e s e t ( ) { v a l u e=0 ; }

/∗@

@ a l s o

@ e n s u r e s c o u n t==\o l d ( c o u n t )+1 ;

@∗/

p u b l i c v o i d i n c r e m e n t ( ) { v a l u e+=1; } }

Exercise 2 Behavioural Subtyping II

a) LetPsuperbe the complete precondition of the supertype andPsubbe the subtype’s additional preconditions for a methodm.

1. What is the complete precondition for methodm?

(2)

2. What is the complete postcondition form, ifQsuperdenotes the complete postcondition of the supertype and Qsubdenotes the subtype’s additional postconditions?

b) Show that the previous results satisfy the conditions 1. pre[Supertype]⇒pre[Subtype]

2. post[Subtype]⇒post[Supertype]

discussed in the lecture.

c) Does JML support strengthening of a method’s complete precondition in a subtype?

Referenzen

ÄHNLICHE DOKUMENTE

En référence à épidémiologie de l’économie et confinement de l’organisation COVID-19 (Moungou Mbenda et Ondoua Biwole 2020), l’apport collectif des chercheurs et

Nelsen and Daniels‟s (2007) definition of quality is invalid according to Routio‟s (2009) criteria as the two parts of this definition ignores the requirements of the

Bu çalışma içerisinde 2001 krizi sonrasında Türk bankacılık sektöründe oluşan yerel para cinsinden kredi- mevduat açığının çapraz kur swapları yoluyla

This paper seeks to contribute to the existing literatures by employing time series econometrics to test the theories that there is long run theoretical

The preceding suggests the fol- lowing answer to the question what goal incremental confirmation is sup- posed to further: Science aims at informative truth, and one should stick

- In case you are applying for a travel grant for junior scientists: Does your supervisor still have collaborative projects with Senckenberg or the Alumnus/a respectively. (please

Concerning lexical access, several communities are concerned: engineers from the natural language generation community (NLG), psychologists 28 , user to provide with the input

Relative unit labor cost (RULC) is the key relative price in the Ricardian model. A rise in RULC is interpreted as a decrease in the competitiveness of Turkey and a decrease of