Class TwoToneCycle

java.lang.Object
  extended by TwoToneCycle

public class TwoToneCycle
extends Object

Class that represents a two tone cycle, similar to those used in telephone ringbacks.

Author:
CSCI 201 student completing HW8.

Constructor Summary
TwoToneCycle()
          Default constructor.
TwoToneCycle(int frequency, double onTimeInSeconds, double offTimeInSeconds)
          Constructor that takes a single frequency.
TwoToneCycle(int frequency1, int frequency2, double onTimeInSeconds, double offTimeInSeconds)
          Constructor that takes two frequencies.
 
Method Summary
 double getFrequency1()
          Accessor method that returns the first frequency
 double getFrequency2()
          Accessor method that returns the second frequency
 double getOffPeriod()
          Accessor method that returns the off period
 double getOnPeriod()
          Accessor method that returns the on period
 Sound makeSound()
          Method that generates a textbook style Sound object
 void setFrequency(int frequency)
          Modifier method to set both frequencies to the same value
 void setFrequency1(int frequency)
          Modifier method to set the first frequency
 void setFrequency2(int frequency)
          Modifier method to set the second frequency
 void setOffPeriod(double timeInSeconds)
          Modifier method to set period in which frequences are off (silent)
 void setOnPeriod(double timeInSeconds)
          Modifier method to set period in which frequences are on (played)
 String toString()
          Method to return the String representation of this two tone cycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TwoToneCycle

public TwoToneCycle()
Default constructor. Generates a US ringback.


TwoToneCycle

public TwoToneCycle(int frequency1,
                    int frequency2,
                    double onTimeInSeconds,
                    double offTimeInSeconds)
Constructor that takes two frequencies.

Parameters:
frequency1 - First frequency
frequency2 - Second frequency
onTimeInSeconds - Length of time frequencies are on (played)
offTimeInSeconds - Length of time frequences are off (silent)

TwoToneCycle

public TwoToneCycle(int frequency,
                    double onTimeInSeconds,
                    double offTimeInSeconds)
Constructor that takes a single frequency.

Parameters:
frequency - Frequency
onTimeInSeconds - Length of time frequency is on (played)
offTimeInSeconds - Length of time frequency is off (silent)
Method Detail

setFrequency1

public void setFrequency1(int frequency)
Modifier method to set the first frequency

Parameters:
frequency - First frequency

getFrequency1

public double getFrequency1()
Accessor method that returns the first frequency

Returns:
First frequency

setFrequency2

public void setFrequency2(int frequency)
Modifier method to set the second frequency

Parameters:
frequency - Second frequency

getFrequency2

public double getFrequency2()
Accessor method that returns the second frequency

Returns:
Second frequency

setFrequency

public void setFrequency(int frequency)
Modifier method to set both frequencies to the same value

Parameters:
frequency - Frequency (both first and second)

setOnPeriod

public void setOnPeriod(double timeInSeconds)
Modifier method to set period in which frequences are on (played)

Parameters:
timeInSeconds - time for the on period (in seconds)

getOnPeriod

public double getOnPeriod()
Accessor method that returns the on period

Returns:
On period

setOffPeriod

public void setOffPeriod(double timeInSeconds)
Modifier method to set period in which frequences are off (silent)

Parameters:
timeInSeconds - time for the off period (in seconds)

getOffPeriod

public double getOffPeriod()
Accessor method that returns the off period

Returns:
Off period

toString

public String toString()
Method to return the String representation of this two tone cycle

Overrides:
toString in class Object
Returns:
String with information about the frequencies and period of the cycle

makeSound

public Sound makeSound()
Method that generates a textbook style Sound object

Returns:
Sound object for the two tone cycle