added ws202425 courses
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
/** Bindung.java
|
||||
*
|
||||
* Eine Klasse, die am Beispiel des figure-Pakets
|
||||
* statische und dynamische Typen ausprobiert
|
||||
*/
|
||||
|
||||
import figure.*;
|
||||
|
||||
class Bindung {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Figure f = new Square();
|
||||
f.moveTo(2,3);
|
||||
f.area();
|
||||
f.show();
|
||||
|
||||
if (f instanceof Square) {
|
||||
((Square)f).show(); // analog: (double)17
|
||||
}
|
||||
|
||||
System.out.println("Flaecheninhalt: " + f.area());
|
||||
f = new Circle(10);
|
||||
System.out.println("Flaecheninhalt: " + f.area());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Bindung
|
||||
Binary file not shown.
@@ -0,0 +1,26 @@
|
||||
|
||||
|
||||
|
||||
public class Verdeckung{
|
||||
|
||||
void display(int n) {
|
||||
int m = 11;
|
||||
System.out.println(String.format("A1: m = %d, n = %d", m, n));
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
Verdeckung v = new Verdeckung();
|
||||
int a = 12;
|
||||
int m = 1;
|
||||
int n = 2;
|
||||
v.display(a);
|
||||
|
||||
if (m == 1) {
|
||||
int x = 22;
|
||||
System.out.println(String.format("A2: m = %d, n = %d", m, x));
|
||||
}
|
||||
System.out.println(String.format("A3: m = %d, n = %d", m, n));
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user