Reputation: 27
I'm doing a weather processor assignment for my computer science class, and I'm having some trouble with a piece of the code. I'm not sure how to approach the issue, so any help would be great. Here is my code:
import java.util.*;
import java.util.GregorianCalendar;
public class Info {
Object data;
String weatherRecord[][][] = new String[0][0][0];
int index = 0;
int HIGHS, LOWS, WIND, GUST, PRECIP;
public void weatherData () {
data = data;
}
final String[] locationNames = {"Eagle, NE", "New York, NY", "Houston, TX", "Los Angeles, CA"};
final int[] monthLength = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
{
for (int i = 0; i < weatherRecord.length; i++) {
GregorianCalendar dateInfo = new GregorianCalendar(2008, 0, 1);
System.out.println((dateInfo.get(Calendar.MONTH) + 1)+ "/" +
dateInfo.get(Calendar.DAY_OF_MONTH)+ "/" +
dateInfo.get(Calendar.YEAR));
for (int j = 0; j < weatherRecord[i].length; j++) {
for (int k = 0; k < monthLength[j]; k++) {
weatherRecord[i][j][k] = new weatherData();
weatherRecord[i][j][k].setLocation(locationNames[i]);
weatherRecord[i][j][k].setDate((GregorianCalendar) dateInfo.clone());
weatherRecord[i][j][k].setHighTemp(data.getHIGHS(index));
weatherRecord[i][j][k].setLowTemp(data.getLOWS(index));
weatherRecord[i][j][k].setWind(data.getWIND(index));
weatherRecord[i][j][k].setGust(data.getGUST(index));
weatherRecord[i][j][k].setPrecip(data.getPRECIP(index));
index++;
dateInfo.add(Calendar.DAY_OF_MONTH, 1);
}
System.out.println((dateInfo.get(Calendar.MONTH)+1) + "/" +
dateInfo.get(Calendar.DAY_OF_MONTH) + "/" +
dateInfo.get(Calendar.YEAR));
}
}
}
private int setLocation(String string) {
// TODO Auto-generated method stub
return 0;
}
}
The part I'm having the trouble with is the data.getHIGHS/LOWS/etc, it tells me that the getHIGHS
method is undefined for the type Object. Where am I going wrong? I have another class that has the getters for the methods in this code.
Upvotes: 0
Views: 1635
Reputation: 48258
The error message means simple that the Object class has no method called getHIGHS, at least not the java.lang.Object
Doc: https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html
It could be possible that you are using some kind of lib that has an Object class, then you have to import that package....
But I will suggest to take a look at the documentation if you are using 3rd part libs.
Upvotes: 2