-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataTable.java
More file actions
40 lines (32 loc) · 1.02 KB
/
Copy pathDataTable.java
File metadata and controls
40 lines (32 loc) · 1.02 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
package work4;
import java.util.HashMap;
import java.util.Map;
public class DataTable {
private String tableName;
private Map<String, Double> data;
private ChartStrategy chartStrategy;
public DataTable(String tableName) {
this.tableName = tableName;
this.data = new HashMap<>();
}
public void addData(String category, Double value) {
data.put(category, value);
}
public Map<String, Double> getData() {
return data;
}
public String getTableName() {
return tableName;
}
public void setChartStrategy(ChartStrategy chartStrategy) {
this.chartStrategy = chartStrategy;
System.out.println("\n--- Встановлено нову стратегію відображення ---");
}
public void display() {
if (chartStrategy == null) {
System.out.println("Стратегію не обрано!");
return;
}
chartStrategy.displayChart(this);
}
}