/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package adt_pair; /** * * @author suchenek */ public class Pair { public Pair() { first = 0; second = 0; } public Pair(double x, double y) { first = x; second = y; } public Pair Add(Pair x) { Pair t = new Pair(); t.first = x.first + this.first; t.second = x.second + this.second; return t; } public double ScalarProd(Pair x) { return this.first*x.first + this.second*x.second; } public double Distance(Pair x) { return Math.sqrt((this.first)*(this.first) + (this.second)*(this.second)); } public String Out() { return ("First = " + this.first + "; Second = " + this.second + ";"); } double first; double second; }