function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
public class PointNew{
//data members
integer x1,y1;
//membr methods
//create
//DC
public PointNew(){
system.debug('DC');
x1=0;
y1=0;
}
//PC
public PointNew(integer x1,integer y1){
//this();
system.debug('PC');
this.x1=x1;
this.y1=y1;
}
//input
public void setvalues(integer x1,integer y1){
this.x1 = x1;
this.y1 = y1;
}
//process
public decimal slope(integer x2,integer y2){
decimal sp;
//system.debug('point is = ('+x2+','+y2+')');
sp=(y2-y1)/(x2-x1);
return sp;
}
public decimal distance(integer x2,integer y2){
decimal ds;
ds = math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
return ds;
}
//output
public void getvalues(){
//system.debug('the points are ('+x1+','+y1+')('+x2+','+y2+')');
system.debug('point is = ('+x1+','+y1+')');
}
}
TEST CLASS
@isTest
public class PointNew_Test{
public static testMethod void name(){
PointNew pt = new PointNew(3,4);
pt.getvalues();
decimal slp = pt.slope(6,15);
system.debug('slope is = '+slp);
decimal ds = pt.distance(4,6);
system.debug('distance is = '+ds);
}
}