-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestMainLab3.java
More file actions
49 lines (37 loc) · 1.74 KB
/
Copy pathTestMainLab3.java
File metadata and controls
49 lines (37 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package work3;
public class TestMainLab3 {
public static void main(String[] args) {
System.out.println("\n=== TASK 1: COMPOSITE PATTERN ===");
// 1. Створення простих елементів
GameElement tree = new SimpleGameElement("Tree", 10, 20);
GameElement rock = new SimpleGameElement("Rock", 5, 5);
GameElement soldier = new SimpleGameElement("Soldier", 2, 6);
// 2. Створення групи (композиту)
CompositeGameElement forest = new CompositeGameElement("Forest");
forest.add(tree);
forest.add(rock);
// 3. Створення вкладеної групи (армія в лісі)
CompositeGameElement army = new CompositeGameElement("Army Squad");
army.add(soldier);
army.add(new SimpleGameElement("General", 2, 6));
// Додаємо армію в ліс
forest.add(army);
// Розрахунок площі
System.out.println("-- Calculating Forest Area --");
forest.getArea();
System.out.println("\n=== TASK 2: BRIDGE PATTERN ===");
// Створення реалізацій (API)
UIGraphicsAPI qtApi = new QtGraphics();
UIGraphicsAPI gtkApi = new GtkGraphics();
// Елементи на Qt
UIElement btnQt = new Button(qtApi, 10, 10, "Submit");
UIElement winQt = new Window(qtApi, 0, 0, 800, 600, "Qt App");
// Елементи на GTK
UIElement btnGtk = new Button(gtkApi, 50, 50, "Cancel");
// Малювання
btnQt.draw();
winQt.draw();
System.out.println("--- Switching library ---");
btnGtk.draw();
}
}