Assertion Execution at Package Level
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   mandeep_singh
Posted On:   Sunday, April 30, 2006 10:13 AM

Hi Friends, I am reading Assertion from Khalid-e-Mugal.On page 254,I am not able to make simple program which shows Assertion Execution at Package Level.I made one but assertion is not enabled in sub package.Also,is assert statement on page 256 is correct. this code also in attachment in file Ref1.java.If boolean expression is false then status will be printed. Also i am sending code in attachment Hope for positive response. Ok GoodBye package pkg2; public class Ref1 { public static void main(String[] args) { int status=-1; if(status==0) {} else if(status>0) {} else {    More>>

Hi Friends,


I am reading Assertion from Khalid-e-Mugal.On page 254,I am not able to make simple program which shows Assertion Execution at Package Level.I made one but assertion is not enabled in sub package.Also,is assert statement on page 256 is correct.


this code also in attachment in file Ref1.java.If boolean expression is false then status will be printed. Also i am sending code in attachment



Hope for positive response.
Ok GoodBye


package pkg2;
public class Ref1
{

public static void main(String[] args)
{

int status=-1;
if(status==0)
{}

else if(status>0)
{}

else
{
assert status <0:"Status value is"+status;
}

}
}


package pkg1;
import pkg2.*;
public class Speed
{

public static void main(String[] args)
{

Speed objRef=new Speed();
//double speed= objRef.calcSpeed(-12.0,3.0);
double speed=objRef.calcSpeed(12.0,-3.0);

//double speed=objRef.calcSpeed(12.0,2.0);


//double speed=objRef.calcSpeed(12.0,0.0);


System.out.println("Speed(km/h):"+speed);


}

private double calcSpeed(double distance,double time)
{

assert distance>=0.0;


assert time>0.0:"Time is not a positive value:"+time;
double speed=distance/time;


assert speed>=0.0;
return speed;br>

}
}

   <<Less
About | Sitemap | Contact