/*
* An example program for count down seconds.
*
* @author: Calvin Feng.
* @date: 2004/07/26
*/
public class CountDown{
public static void main(String args[]){
if (args.length < 1){
System.out.println("Usage: java CountDown [seconds]");
return;
}
try{
for (int i = Integer.parseInt(args[0]); i >= 0; i--){
System.out.print( "Count down(seconds) ");
for (int j = args[0].length() - Integer.toString(i).length(); j > 0; j--)
System.out.print("0");
System.out.print(i + "");
if (i > 0)
Thread.sleep(1000);
}
System.out.println();
System.out.println("Time is up!");
}catch(Exception e){
e.printStackTrace();
}
}
}
在公司剛好沒事做,一直看時間,於是就自己寫個倒數時間的程式,不過,是輸入秒數讓他倒數啦..哈~
* An example program for count down seconds.
*
* @author: Calvin Feng.
* @date: 2004/07/26
*/
public class CountDown{
public static void main(String args[]){
if (args.length < 1){
System.out.println("Usage: java CountDown [seconds]");
return;
}
try{
for (int i = Integer.parseInt(args[0]); i >= 0; i--){
System.out.print( "Count down(seconds) ");
for (int j = args[0].length() - Integer.toString(i).length(); j > 0; j--)
System.out.print("0");
System.out.print(i + "");
if (i > 0)
Thread.sleep(1000);
}
System.out.println();
System.out.println("Time is up!");
}catch(Exception e){
e.printStackTrace();
}
}
}
在公司剛好沒事做,一直看時間,於是就自己寫個倒數時間的程式,不過,是輸入秒數讓他倒數啦..哈~
全站熱搜
留言列表