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 18/06/2021 Esercizio 1 Si consideri la seguente classe Java SensorsData per salvare e analizzare valori di temperatura provenienti da sensori ambientali. Ogni sensore `e rappresentato da un identificativo univoco di tipo String e ogni valore di temperatura `e rappresentata da un float. Per ogni sensore sono salvati solo i 100 valori di temperatura pi`u recenti. p u b l i c c l a s s S e n s o r s D a t a{ / / R i t o r n a g l i i d e n t i f i c a t i v i d i t u t t i i s e n s o r i per c u i e ’ s a l v a t o / / almeno un v a l o r e d i t e m p e r a t u r a . p u b l i c / *@ pure @ * / Set <S t r i n g> s e n s o r s ( ) ; / / R i t o r n a i l numero d i v a l o r i s a l v a t i per i l s e n s o r e con i d e n t i f i c a t i v o i d . p u b l i c / *@ pure @ * / i n t numValuesFor ( S t r i n g i d ) ; / / R i t o r n a l ’ i −esimo v a l o r e d i t e m p e r a t u r a s a l v a t o per i l s e n s o r e con i d e n t i f i c a t i v o i d . / / I v a l o r i sono i n o r d i n e d i i n s e r i m e n t o , d a l meno r e c e n t e ( p o s i z i o n e 0 ) a l / / p i u ’ r e c e n t e ( p o s i z i o n e 9 9 ) . p u b l i c / *@ pure @ * / f l o a t g e t V a l u e ( S t r i n g id , i n t i ) ; / / Aggiunge i l v a l o r e d i t e m p e r a t u r a temp per i l s e n s o r e con i d e n t i f i c a t i v o i d ( a g g i u n g e n d o l o / / s e non p r e s e n t e ) . Se sono g i a ’ s a l v a t i 100 v a l o r i , i l meno r e c e n t e v i e n e c a n c e l l a t o . p u b l i c v o i d add ( S t r i n g id , f l o a t temp ) ; / / R i t o r n a l ’ i n s i e m e d i i d e n t i f i c a t i v i d i t u t t i i s e n s o r i per c u i l a somma / / d e i v a l o r i r e g i s t r a t i s u p e r a i l v a l o…
First page of the document.