001    package de.hska.java.aufgaben.interfaces;
002    
003    /**
004     * Eine Implementierung von Punkt mit x- und y-Koordinate.
005     * 
006     * <p>
007     *   <a href="http://www.home.hs-karlsruhe.de/~pach0003/informatik_1/aufgaben/interfaces.html#punkt">Zurück zum Aufgabentext</a>
008     * </p>
009     * 
010      * 
011     * @author Christian Pape
012     *
013     */
014    public class PunktKartesisch implements Punkt {
015    
016            private double x;
017            private double y;
018            
019        /**
020         * Erzeugt einen neuen Punkt mit den beiden gegebenen
021         * kartesischen Koordinaten x und y
022         */
023            public PunktKartesisch(double x, double y) {
024                    this.x = x;
025                    this.y = y;
026            }
027        
028            public double getAbstand(Punkt punkt) {
029                    return Math.sqrt( (x - punkt.getX()) * (x - punkt.getX())
030                                              + (y - punkt.getY()) * (y - punkt.getY())  );
031            }
032    
033            public double getX() {
034                    return x;
035            }
036    
037            public double getY() {
038                    return y;
039            }
040    
041    }