tried to fix but still getting errors..plz help!!!
thanx for the help...
i tried to make the changes u suggested. i am getting an error related to the object i'm creating in main. please help me!!!
here is my new program....
public final class InRange {
//param aName has content.
//param aSpeed is in the range 0 (inclusive) to 1 (inclusive), and
//exception IllegalArgumentException if a param does not comply.
public InRange ( String aName, double aSpeed ) {
if ( !textHasContent(aName) ) {
throw new IllegalArgumentException("Name has no content.");
}
if ( aSpeed < 0.0 || aSpeed > 1.0 ) {
throw new IllegalArgumentException("Speed not in range [0..1]: " + aSpeed);
}
fName = aName;
fSpeed = aSpeed;
}
private String fName;
private double fSpeed;
// Returns true if aText is non-null and has visible content.
private boolean textHasContent( String aText )
{
String emptyString = "";
return (aText != null) && (!aText.trim().equals(emptyString));
}
public static void main(String args[])
{
InRange part;
String row="";
String row1 = "Siddiqui";
String string1="Sabeen";
double number=2.0;
double num=1.5;
try
{
part(string1, num);
System.out.println("Lookng for exception");
}
catch(IllegalArgumentException ex)
{
System.out.println(ex);
//System.out.println("Empty string causes an exception.");
}
System.out.println("main: " + InRange.class.getName() + " ended");
}
}
thanx
sabeen:confused: