Document information
- University
- Politecnico di Milano
- Degree programme
- Computer Engineering
- Subject
- Ingegneria del Software
- Classification
- Exam · Full exam
- Content
- Exam paper only
- Original format
- Text
- Searchable text
Study material for Ingegneria del Software, shared by the Studwiz community and reviewed by moderators.
Study material for Ingegneria del Software, shared by the Studwiz community and reviewed by moderators.
Import quality: text was extracted directly from the original document.
Representative passages recognised in different parts of the material. The full extracted text remains available to search, while this compact preview makes the page easier to read.
Ingegneria del Software — SOLUZIONE DEL TEMA 10 settembre 2020 Esercizio 1 Si consideri la seguente classe ImmList<T> che definisce una lista immutabile di elementi di tipoT. p u b l i c / *@ p u r e @ * / c l a s s ImmList <T> { / / R i t o r n a t r u e s e e s o l o s e l a l i s t a e ’ v u o t a p u b l i c b o o l e a n empty ( ) ; / / R i t o r n a i l p r i m o e l e m e n t o d e l l a l i s t a / / L a n c i a E m p t y E x c e p t i o n s e l a l i s t a e ’ v u o t a p u b l i c T f i r s t ( ) throws EmptyException ; / / R i t o r n a una nuova l i s t a i d e n t i c a a t h i s ma s e n z a i l p r i m o e l e m e n t o / / I n c a s o d i l i s t a v u o t a , r i t o r n a una nuova l i s t a v u o t a p u b l i c ImmList <T> t a i l ( ) ; / / R i t o r n a una nuova l i s t a c h e c o n t i e n e e l i n u l t i m a p o s i z i o n e / / L a n c i a N u l l E x c e p t i o n s e e l e ’ n u l l p u b l i c ImmList <T> add ( T e l ) throws N u l l E x c e p t i o n ; / / R i t o r n a i l numero d i o c c o r r e n z e d e l l ’ e l e m e n t o e l n e l l a l i s t a p u b l i c i n t c o u n t ( T e l ) } Domanda a) Si scriva la specifica JML del metodoadd. Soluzione / / @ensures e l != n u l l & & \ r e s u l t != n u l l & & / / @ t h i s . e m p t y ( ) ==> / /@ ( \ r e s u l t . f i r s t ( ) . e q u a l s ( e l ) & & \ r e s u l t . t a i l ( ) . e m p t y ( ) ) & & / /@! t h i s . e m p t y ( ) == > / /@ ( \ r e s u l t . f i r s t ( ) . e q u a l s ( f i r s t ( ) ) & & \ r e s u l t . t a i l ( ) . e q u a l s ( t a i l ( ) . add ( e l ) ) ) / /@ / / @ s i g n a l s N u l l E x c e p t i o n e l == n u l l p u b l i c ImmList <T> add ( T e l ) throws N u l l E x c e p t i o n ; Domanda b) Si scriva la specifica JML del metodocount. Soluzione /…
First page of the document.