Results 1 to 6 of 6
- 11-20-2008, 09:17 PM #1
Member
- Join Date
- Nov 2008
- Posts
- 7
- Rep Power
- 0
Error that i should know how to fix.
Ok Im getting this dumb error and I think I have to initialize something just not quite sure how.
Or maybe Im writing it wrong
the error im getting is "variable tempStation might not have been initialized"
I have the location of the error marked with a smiley face.
Any help would be greatly appreciated.
thanks
dorno83
/**
* Locator - provides data for stations and zip code zones and methods
* to access them.
*
* @author John Fulton
* @author Ray Waite
* @version 20080830
*/
public class Locator
{
// array sizes (and limits)
private final static int STATION_LIMIT = 100;
private final static int POSTAL_ZONE_LIMIT = 100;
// instance variables
private Station [] stationArray;
private PostalZone [] postalZoneArray;
private int nextStation;
private int nextPostalZone;
/**
* Constructor for objects of class Locator.
*/
public Locator()
{
this.stationArray = new Station[STATION_LIMIT];
this.postalZoneArray = new PostalZone[POSTAL_ZONE_LIMIT];
nextStation = 0;
nextPostalZone = 0;
}
/**
* addStation - add a station to the array of stations.
*
* @param inputNumber int Station number to add
* @param inputDescription String Station description to add
* @param inputLocation String Location of station
*
* @return int index of added station, -1 if unable to
* add (array already full)
*/
public int addStation(int inputNumber, String inputDescription,
Location inputLocation)
{
// replace with your code
if (nextStation > 99)
{
return -1;
}
Station tempStation = new Station(inputNumber, inputDescription,
inputLocation);
stationArray[nextStation] = tempStation;
return nextStation++;
}
/**
* addStation - add a station to the array of stations.
*
* @param inputStation Station zipZone to be added
* @return int index of added station, -1 if unable to
* add (array already full)
*/
public int addStation(Station inputStation)
{
// replace with your code
if (nextStation > 99)
{
return -1;
}
:) Station tempStation = new Station(tempStation.getStationNumber(),
tempStation.getDescription(), tempStation.getStationLocation());
stationArray[nextStation] = tempStation;
return nextStation++;
}
/**
* addPostalZone - add a zip code zone to the array of PostalZones.
*
* @param inputZipCode int zip code of zipZone to add
* @param inputLocation Location location object for zipZone to add
*
* @return int index of added zipZone, -1 if unable to
* add (array already full)
*/
public int addPostalZone(int inputZipCode, Location inputLocation)
{
//replace with your code
if (nextPostalZone > 99)
{
return -1;
}
PostalZone tempPostalZone = new PostalZone(inputZipCode, inputLocation);
postalZoneArray[nextPostalZone] = tempPostalZone;
return nextPostalZone++;
}
/**
* addPostalZone - add a zip code zone to the array of PostalZones.
*
* @param inputPostalZone PostalZone zipZone to be added
*
* @return int index of added zipZone, -1 if unable to
* add (array already full)
*/
public int addPostalZone(PostalZone inputPostalZone)
{
//replace with your code
if (nextPostalZone > 99)
{
return -1;
}
PostalZone tempPostalZone = new PostalZone(tempPostalZone.getZipCode(),
tempPostalZone.getZipLocation());
postalZoneArray[nextPostalZone] = tempPostalZone;
return nextPostalZone++;
}
/** postalZoneExists - indicates whether PostalZone exists.
*
* @param zipCode int zipCode of PostalZone to find
*
* @return boolean true is zipZone exists in zipArray,
* false otherwise
*/
public boolean postalZoneExists(int zipCode)
{
//replace with your code
for (int i = 0; i < nextPostalZone; i++)
{
if (zipCode == postalZoneArray[i].getZipCode());
{
return true;
}
}
return false;
}
/** findPostalZone - find and return PostalZone object.
*
* @param zipCode int zipCode of ZipZone to find
*
* @return ZipZone if found, returns zip zone object,
* if not found, returns null reference
*/
public PostalZone findPostalZone(int zipCode)
{
// replace with your code
for (int i = 0; i < nextPostalZone; i++)
{
if (zipCode == postalZoneArray[i].getZipCode());
{
return postalZoneArray[i];
}
}
return null;
}
/** toString - overrides method in base Object class.
*
* @return string values stationd in Station and PostalZone arrays,
* formatted for printing
*/
public String toString()
{
// replace with your code
return "not correct";
}
}
- 11-21-2008, 04:26 AM #2
Member
- Join Date
- Nov 2008
- Posts
- 7
- Rep Power
- 0
Anyone????
- 11-21-2008, 04:39 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Can you copy-paste the full error message here to see.
- 04-03-2009, 04:16 PM #4
As someone who is just learning I may well be on the wrong track but there is no tempStation in your declaration of variables that you have commented near the top of your code (instance variables)????
Maybe?
- 04-03-2009, 05:51 PM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Different people have different styles. But better to follow the commons as well. ;)
- 04-03-2009, 10:06 PM #6
Similar Threads
-
error 530 error authentication required
By rgale in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 05-12-2008, 04:28 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks