/** * Class for creating a template for a simple Java program * * @author Pat Troy: troy AT uic DOT edu */ import java.awt.Color; // Note the name of the class in the following line MUST // match the name of the file. public class Lect1130a { public static void main (String[] args) { int intArray[] = new int [50]; for (int index = 0 ; index < intArray.length ; ++index ) { intArray [index] = 5 * index; } for (int index = 0 ; index < intArray.length ; ++index ) { System.out.print (intArray[index] + ", "); if (index % 10 == 9) System.out.println(); } Color myArray[]; int size = 100; myArray = new Color [size]; for ( int index = 0 ; index < myArray.length ; ++index ) { myArray [index] = new Color (index * 2, 0, 255 - index * 2); } int s3[]; s3 = reverseArray (intArray); for (int index = 0 ; index < s3.length ; ++index ) { System.out.print (s3[index] + ", "); if (index % 10 == 9) System.out.println(); } //s3.explore(); } public static int[] reverseArray (int arr[]) { int s2[] = new int [arr.length]; for (int i = 0 ; i < arr.length ; ++i) { s2[arr.length - 1 - i] = arr[i]; } return s2; } public static Sound reverseSound (Sound s1) { SoundSample sampArr1[] = s1.getSamples(); SoundSample samp1; int index; int sampVal1; int index2; System.out.println ("Number of samples in the sound: " + sampArr1.length); for ( index = 0 ; index < (sampArr1.length / 2) ; index++ ) { index2 = sampArr1.length - index - 1; swap (sampArr1[index], sampArr1[index2]); } return s1; } public static void swap (SoundSample samp1, SoundSample samp2) { int temp = samp1.getValue(); samp1.setValue ( samp2.getValue() ); samp2.setValue ( temp ); } } // end of class