/*
* Title: WeatherStationList.java
* Description: this implements and manages a list of inventory items...
*/
import java.text.DecimalFormat;//in order to display in decimal format
import java.text.NumberFormat;//same
import java.util.*;
public class WeatherStationList {
private int MaxSize = 25; //The value here is the List's absolute size...
private int CurrSize = 0; //The number of item currently list...
public WeatherStationData[] List = new WeatherStationData[MaxSize];
//Define the core methods for the list...
//First a way to add items to the list...
public void Add(String ID, double Temp)
{
if(CurrSize < MaxSize) { //Make sure there's room...
List[CurrSize] = new WeatherStationData(ID, Temp); //Then add it...
CurrSize++; //Bump the count up, because there's one more...
}
else
System.out.println("Sorry List Is Full"); //Whoops! no more room...
}
public void Display()
{
int K;
for(K = 0 ; K < CurrSize ; K++) {
if(List[K] != null) {
NumberFormat Rounder = new DecimalFormat("#0.00"); //displays in 0.00 decimal format
System.out.println("Weather Station: " + List[K].GetID()); //gets station id
System.out.println("Temperature: " + List[K].GetTemp() + " " + Rounder.format(((5*(List[K].GetTemp()-32))/9)));//shows temp in F and Celcius
}
}
}
[B]public void Display2()
{
[QUOTE]What Code Do i enter here to sort the list by the value of the Double Temp?
Arrays.sort(List);
[/QUOTE]
System.out.println("Highest Temperature: " + List[0].GetID() + List[0].GetTemp());
System.out.println("Lowest Temperature: " + List[CurrSize].GetID() + List[CurrSize].GetTemp());
}[/B]
}