Snippets

Ettar Java Punkt

Created by Ettar
public class Punkt {
    private double x;
    private double y;

    public Punkt(double x, double y){
        setX(x);
        setY(y);
    }

    public void setX(double x) {
        this.x = x;
    }

    public void setY(double y) {
        this.y = y;
    }

    public double getX() {
        return x;
    }

    public double getY() {
        return y;
    }
}
1
2
3
4
5
6
7
8
9
public class PunktTest{
    public static void main(String[] ARGS){
        Punkt nP = new Punkt(2.0,3.0);
        System.out.println(nP.getX() + " " + nP.getY());
        nP.setX(4.0);
        nP.setY(7.0);
        System.out.println(nP.getX() + " " + nP.getY());
    }
}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.