Write a method in the Picture class to convert a Picture object into a Sound object using the average of the color values. Map all values from 0 to 84 to the maximum negative sound value, map all values from 85 to 169 to 0 and all values above 170 to the maximum positive value.
What will be an ideal response?
```
/? ?
? Method t o c o n v e r t a p i c t u r e i n t o a sound
? @return t h e r e s u l t i n g sound
?/
public Sound convertToSound ( )
{
Pixel [ ] pixelArray = this . g e t P i x e l s ( ) ;
P i x e l c u r r P i x e l = null ;
Sound aSound = new Sound ( p i x e l A r r a y . l e n g t h ) ;
// l o o p t h r o u g h p i x e l a r r a y
f o r ( i n t i = 0 ; i < p i x e l A r r a y . l e n g t h ; i ++)
{
currPixel = pixelArray [ i ] ;
double a v e r a g e = c u r r P i x e l . g e t A v e r a g e ( ) ;
// map t h e a v e r a g e t o a sound v a l u e
i f ( a v e r a g e <= 8 4 )
aSound . setSampleValueAt ( i , Sound .MAX NEG) ;
e l s e i f ( a v e r a g e <= 1 6 9 )
aSound . setSampleValueAt ( i , 0 ) ;
else
aSound . setSampleValueAt ( i , Sound .MAX POS ) ;
}
return aSound ;
}
```
You might also like to view...
Which message type supports functionality for reachability utilities like Ping and Tracert; essential when installing, configuring, and troubleshooting IP networks?
A. ICMP Echo/Echo Reply B. ICMP Source Quench C. ICMP Time Exceeded D. ICMP Destination Unreachable
An accumulator is the same thing as a counter that you use to count loop iterations.
Answer the following statement true (T) or false (F)
A ____ protects your system from intruders.
A. firewall B. digital wallet C. digital certificate D. none of the above
An advantage of distributed data processing is that individual end user groups set specific IT standards without concern for the broader corporate needs.
Answer the following statement true (T) or false (F)