CSE 8A: Winter 2013
  • Home
  • Calendar
  • Assignments/Labs
  • Course Material
  • Tutor Hours
  • Lab Schedule

Problem Solving Assignment #7

Turnin for Extra Credit due Sunday, February 24th, 11:59 pm
Turnin due Monday, February 25th, 11:59 pm
Interview due Thursday, February  28th, 11:59 am

This homework requires skills from all Chapters up to Chapter 6 and Chapter 8.

There are three problems in this PSA.

  1. Checking Boundaries -- Alter PSA4 so that the user can input any location and any size to flip and the program will not get an out of bounds error.
  2. Concatenating Sounds -- Using Sound.java, concatenate two sounds together.
  3. Sound Palindrome -- Using Sound.java and your concatenate method from part 2, you will create a sound which is played forward and then in reverse. Your main role in this problem will be writing the reverse method. For more information about palindromes, see the Wikipedia page.

Setup

1) Right-click in an open space on the Desktop and select 'Open in Terminal' from the drop down menu.
    (it will bring up the following window)
Picture
2) Highlight the following 10 lines with the mouse, right-click to copy:
    cd ../public/PSA7
    make directories
    make install
    cd 
    cd PSA7
    mv PSA7A.java.empty PSA7A.java
    mv PSA7B.java.empty PSA7B.java
    mv PSA7C.java.empty PSA7C.java
    mv Picture.java.empty Picture.java
    mv Sound.java.empty Sound.java
    ls

3) Select the terminal window with the mouse and right-click to paste.
4) Verify that the 'PSA7A.java', 'PSA7B.java', 'PSA7C.java', 'Picture.java' and the 'Sound.java' files are shown as the result of the last command.

    Following these procedures, your files will be named correctly and be located in the correct places. For every assignment you need to follow correct           
    naming of assignments in the correct locations to get credit for your work.
5) Proceed to start your programming assignment. You must write your code in the files in your PSA7 folder.

Problem

Checking Boundaries

Testing your method (in an application) (4 pts):

  • For this part of the assignment, you will copy these methods into your Picture.java, and make some changes to this file.
  • Find a way to alter PSA7A.java in order to allow the user to input ANY numbers for a box to flip.
  • For example, if the user inputs 2,5,100, your program should print: This range is out of bounds. Please choose a range that is within (0,0) and (width ,height ), where width and height are the actual width and height of the picture chosen.
  • If the user enters constraints that will not cause an out of bounds error, then flip that portion of the picture and continue.
  • If the user enters constraints that will cause an out of bounds error, then reprompt them. This should not count towards the 3 flips for each vertical and horizontal. There should still be a total of 6 FLIPS; 3 horizontal, 3 vertical.  

Sound Editing

Method: concatenation (4 pts total for this method)
  • This method will modify the calling object and the calling object will be assumed to be a silent wave file (there are two in your mediasources directory - sec1silence.wav and sec3silence.wav - and you can create others). It will take as parameters Sound a, Sound b, and an integer "switchPoint" which denotes the frame at which to switch from a to b.
  • The method will overwrite the calling object with Sound a, then with Sound b. You will switch between a and b when either Sound a finishes or when you hit the switchPoint (whichever is earlier). You will then (either at the switchPoint or the end of Sound a) begin Sound b. (Your code must support the switchPoint being before or after the end of Sound a, regardless of how you use it when testing.)
  • If the length of Sound a and Sound b is less than the length of the calling object your program should not fail and should leave the remaining portion of the calling object as silent.
Testing your method (in an application) (2 pts):
  • Create a new file called PSA7B.java where you will write an application to test your methods.
  • Your application will do the following:
    • Open three Sound files (one of which is silence) and play the two Sound files which are not silence using the method blockingPlay(). 
    • You will then call concatenation using those three files. Play the resulting Sound using the blockingPlay() method. 
  • IMPORTANT In order for the grader to grade your submission your code must work with different paths. To obtain each media file, do NOT use the file path or MediaPath functions. Copy the sounds you want to use for your final submission into the same folder as your code and rename them Sound1.wav, Sound2.wav and Sound3.wav. Then ensure that the file path is simply "soundname.wav". For example, if you want to use Sound1.wav, use
    • String fileName = "Sound1.wav";
    • Sound s = new Sound(fileName);
Sound Palindrome

Method: soundPalindrome

* This method will use the calling object as the sound which will be reversed then concatenated. It will return the desired sound. You can get the code which you will add to Sound.java here. You will not edit this code, just use it. 

Method: reverse (4 pts)

* This method will be used by soundPalindrome to reverse a sound. It will return a Sound object which is the reverse of the calling object.

Testing your method (in an application)  (2 pts):

* Create a new file called PSA7C.java where you will write an application to test your methods.
* Your application will do the following:
o Open one Sound file and play it using the method blockingPlay(). 
o You will then call soundPalindrome using that file as the calling object. Then play the resulting Sound using the blockingPlay() method. 
* IMPORTANT In order for the grader to grade your submission your code must work with different paths. To obtain each media file, do NOT use the file path or MediaPath functions. Copy the sound you want to use for your final submission into the same folder as your code and rename it Sound4.wav. Then ensure that the file path is simply "Sound4.wav". For example, if you want to use Sound4.wav, use
o String fileName = "Sound4.wav";
o Sound s = new Sound(fileName);

How to turnin your homework

1)   Open the terminal

2)   cd PSA7

3)   autograder login -e yourucsdemailhere -p (wait for password prompt)

4)   type in your password

5)   turnin PSA7

Powered by Create your own unique website with customizable templates.