ItemTypesLists.java:79: error: incompatible types: Market cannot be converted to Zip
return ZipList.get(index);
^
ItemTypesLists.java:83: error: incompatible types: Market cannot be converted to TF
return TFList.get(index);
I Have a market class with extends of TF for t/f and Zip. Purpose is to read a data file and split them between the classes. One could contain a zip code or a false/true input at the end.
Nevada, 35000, true
Oregon, 12500, 97001
California, 38000
Texas, 25000
Florida, 15000, false
public class ItemTypesLists {
private ItemOrderedList ZipList;
private ItemOrderedList TFList;
public ItemTypesLists() {
ZipList = new ItemOrderedList();
TFList = new ItemOrderedList();
}
public void add(Object element) {
if (element instanceof Zip) {
ZipList.add((Zip) element);
} else if (element instanceof TF) {
TFList.add((TF) element);
}
}
public int sizeOfZip() {
return ZipList.size();
}
public int sizeOfTF() {
return TFList.size();
}
public void displayZip() {
ZipList.display();
}
public void displayTF() {
TFList.display();
}
public boolean add(int index, Market element) {
if (element instanceof Zip) {
return ZipList.add(index,(Zip) element);
} else if (element instanceof TF) {
return TFList.add(index, (TF) element);
}
return false;
}
public boolean remove(Market target) {
if (target instanceof Zip) {
return ZipList.remove((Zip) target);
} else if (target instanceof TF) {
return TFList.remove((TF) target);
}
return false;
}
public boolean removeZip(Zip index) {
return ZipList.remove(index);
}
public boolean removeTF(TF index) {
return TFList.remove(index);
}
public int indexOf(Market target) {
if (target instanceof Zip) {
return ZipList.indexOf((Zip) target);
} else if (target instanceof TF) {
return TFList.indexOf((TF) target);
}
return -1;
}
public Zip getZip(int index) {
return ZipList.get(index);
}
public TF getTF(int index) {
return TFList.get(index);
}
}
New contributor
Chi Lee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
5