Temperature
This program dispaly weekly temperatures. weekTemp is a list of items for each day of a week. len is the number of elements for each day. The structure is {day high low}. You can get yesterday and tomorrow by computing.
public void WeekTemp(DayTemperature[] weekTemp)
{
int n = 0;
int m = weekTemp.length;
for (int i=0; i<m; i++) {
String yesterday, tomorrow;
// get days by mod computing
if (i == 0) {
yesterday = weekTemp[m-1].day;
} else {
yesterday = weekTemp[i-1].day;
}
if (i >= m) {
tomorrow = weekTemp[0].day;
} else {
tomorrow = weekTemp[i+1].day;
}
'accept' goes to yesterday card and 'options' goes to tomorrow card.
dispaly today's high tempture and low tempture.
_card( "id='card_$day' title='$day'" );
_do( "type='accept' label='" + yesterday + "'" );
__go( "href='#card_" + yesterday + "'" );
do_();
_do( "type='options' label='" + tomorrow + "'" );
__go( "href='#card_" + tomorrow + "'" );
do_();
_p( "align='center'" );
quote( "Today " + weekTemp[i].day + " Temp " );
__br(); __br();
quote( "High: "
+ Integer.toString( weekTemp[i].high ) );
__br();
quote( "Low: "
+ Integer.toString( weekTemp[i].low ) );
p_();
card_();
}
}
set temp as a list of {day high low}. The attribute http-equiv specifies the cache control
which is interpreted by HTTP server. content='max-age=0' will upgrade the cache
immediately. forua='true' specifies that the property will reach to microbrowser.
// {day high low}
public class DayTemperature
{
String day;
int high;
int low;
}
DayTemperature[] temp = {
{Sun, 79, 30}, {Mon, 68, 20},
{Tue, 74, 32}, {Wed, 77, 40},
{Thu, 73, 38}, {Fri, 69, 39},
{Sat, 71, 41}
};
wmlHeader();
_wml();
_head();
__meta( " http-equiv='Cache-Control'"
+ " content='max-age=0'"
+ " forua='true'" );
__meta( " http-equiv='Cache-Control'"
+ " content='must-revalidate'"
+ " forua='true'" );
head_();
WeekTemp( temp );
wml_();
|