This commit is contained in:
Luca Conte 2022-10-27 21:25:31 +02:00
parent 510e2489e8
commit 7a01aa1c9d
3 changed files with 9 additions and 7 deletions

View File

@ -7,9 +7,9 @@ public class Swap {
System.out.println("p1: ("+p1.x+", "+p1.y+")");
System.out.println("p2: ("+p2.x+", "+p2.y+")");
}
public static void swapPoints(Point p1, Point p2) {
Point ptmp = new Point(p1.x, p1.y);
Point ptmp = new Point(p1);
p1.setLocation(p2.x, p2.y);
p2.setLocation(ptmp.x, ptmp.y);
}

BIN
u11/Scale.class Normal file

Binary file not shown.

View File

@ -1,15 +1,17 @@
import java.awt.Point;
public class Scale {
public static void main(String[] args) {
int x= 4;
int y= 3;
int faktor= 2;
// ... hier kommt der Code hin (ggf. mehrere Anweisungen),
// der zum Aufruf der Methode skaliere benötigt wird
Point p = new Point(x,y);
skaliere(p, faktor);
System.out.println();
System.out.println(p.x + " " + p.y);
}
// Hier fehlt Ihre Methode skaliere
public static void skaliere(Point p, int faktor) {
p.setLocation(p.x * faktor, p.y * faktor);
}
}