Arieccomi con un nuovo test.
codice:
import java.util.*;
public class TestSheet {
public static void main(String[] args) {
Spreadsheet spreadsheet = new SimpleSpreadsheet();
List<WorkSheet> list = spreadsheet;
// this should be respected
assert (list.get(0) instanceof Map<Coordinates,Object>);
assert spreadsheet.size() == 1;
spreadsheet.get(0).put(new Coordinates("A1"), new Integer(5));
}
Dovrei creare delle classi che validano questo test.
Ho creato dunque:
codice:
public class SimpleSpreadsheet extends Spreadsheet{
public SimpleSpreadsheet(){
super();
}
}
public class Spreadsheet extends ArrayList<WorkSheet>{
public Spreadsheet(){
this.add(new WorkSheet("A0", 0));
}
}
public class WorkSheet<K,V> extends HashMap<K,V>{
public WorkSheet(){
super(0);
}
}
public class Coordinates{
String coord;
public Coordinates(String coord){
this.coord = coord;
}
}
compilando mi da un errore
codice:
illegal generic type for instanceof
sulla riga
codice:
assert (list.get(0) instanceof Map<Coordinates,Object>);
Qualche consiglio?