I'm trying to create a factory that contains chart types but I'm getting a cannot find symbol error on my this.map.put(chart.nc);
under nc and I have no idea why, can anyone tell me what I'm doing wrong?
private enum ChartType { BAR, PIE, LINE, SQUARE };
private final Map<ChartType,DataComponent> map = new HashMap<>();
public DataComponent createChart(ChartType chart){
DataComponent nc = this.map.get(chart);
if (nc == null){
switch(chart){
case BAR: nc = new BarChart(); break;
case PIE: nc = new PieChart(); break;
case LINE: nc = new LineGraph(); break;
case SQUARE: nc = new SquareChart(); break;
}
this.map.put(chart.nc);
}
return nc;
}
}