vonko1988

JSON

May 11th, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var lineConstructor = function lineConstructor(input0,input1,input2,input3) {
  2.  
  3.     return {
  4.         point1: {
  5.             x: input0,
  6.             y: input1
  7.         },
  8.  
  9.         point2: {
  10.             x: input2,
  11.             y: input3
  12.         },
  13.  
  14.         calculateLine: function () {
  15.             return (Math.sqrt(Math.abs(this.input0.x - this.input1.x) *
  16.                 Math.abs(input2.y - this.input3.y)));
  17.         }
  18.     }
  19.  
  20. }
  21.  
  22. var line1 = lineConstructor(3, 4, 5, 6);
  23. var line2 = lineConstructor(-2, -5, 7, 10);
  24.  
  25. console.log(line1.calculateLine());
Advertisement
Add Comment
Please, Sign In to add comment