function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Naresh Kumar Mohan ThirukkovaluruNaresh Kumar Mohan Thirukkovaluru 

In dis code, slope value is not coming in decimal & my sir said dis program is wrong, I have to think in OOPS perspective(wats dis mean)? plz clarify dis

Naresh Kumar Mohan ThirukkovaluruNaresh Kumar Mohan Thirukkovaluru
BUSINESS CLASS
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);
       
    }
}