2014年3月23日日曜日

開発環境

Head First Java 第2版 ―頭とからだで覚えるJavaの基本(Kathy Sierra (著)、Bert Bates (著)、島田 秋雄 (監修)、神戸 博之 (監修)、高坂 一城 (監修)、夏目 大 (翻訳)、オライリージャパン)の10章(数値の扱いとスタティック変数、メソッッド)、プログラミングマグネット(p.312)を解いてみる。

プログラミングマグネット(p.312)

コード(BBEdit, Emacs)

FullMoons.java

import java.util.*;
import static java.lang.System.out;

class FullMoons {
    static int DAY_IM = 1000 * 60 * 60 * 24;

    public static void main(String [] args) {
        Calendar c = Calendar.getInstance();
        
        c.set(2004, 0, 7, 15, 40);
        for (int x  = 0; x < 60; x++) {            
            long day1 = c.getTimeInMillis();
            day1 += (DAY_IM * 29.52);            
            c.setTimeInMillis(day1);
            out.println(String.format("full mmon on %tc", c));
        }
    }
}

入出力結果(Terminal)

$ javac FullMoons.java && java FullMoons
full mmon on Fri Feb 06 04:09:15 JST 2004
full mmon on Sat Mar 06 16:38:03 JST 2004
full mmon on Mon Apr 05 05:06:51 JST 2004
full mmon on Tue May 04 17:35:39 JST 2004
full mmon on Thu Jun 03 06:04:27 JST 2004
full mmon on Fri Jul 02 18:33:15 JST 2004
full mmon on Sun Aug 01 07:02:03 JST 2004
full mmon on Mon Aug 30 19:30:51 JST 2004
full mmon on Wed Sep 29 07:59:39 JST 2004
full mmon on Thu Oct 28 20:28:27 JST 2004
full mmon on Sat Nov 27 08:57:15 JST 2004
full mmon on Sun Dec 26 21:26:03 JST 2004
full mmon on Tue Jan 25 09:54:51 JST 2005
full mmon on Wed Feb 23 22:23:39 JST 2005
full mmon on Fri Mar 25 10:52:27 JST 2005
full mmon on Sat Apr 23 23:21:15 JST 2005
full mmon on Mon May 23 11:50:03 JST 2005
full mmon on Wed Jun 22 00:18:51 JST 2005
full mmon on Thu Jul 21 12:47:39 JST 2005
full mmon on Sat Aug 20 01:16:27 JST 2005
full mmon on Sun Sep 18 13:45:15 JST 2005
full mmon on Tue Oct 18 02:14:03 JST 2005
full mmon on Wed Nov 16 14:42:51 JST 2005
full mmon on Fri Dec 16 03:11:39 JST 2005
full mmon on Sat Jan 14 15:40:27 JST 2006
full mmon on Mon Feb 13 04:09:15 JST 2006
full mmon on Tue Mar 14 16:38:03 JST 2006
full mmon on Thu Apr 13 05:06:51 JST 2006
full mmon on Fri May 12 17:35:39 JST 2006
full mmon on Sun Jun 11 06:04:27 JST 2006
full mmon on Mon Jul 10 18:33:15 JST 2006
full mmon on Wed Aug 09 07:02:03 JST 2006
full mmon on Thu Sep 07 19:30:51 JST 2006
full mmon on Sat Oct 07 07:59:39 JST 2006
full mmon on Sun Nov 05 20:28:27 JST 2006
full mmon on Tue Dec 05 08:57:15 JST 2006
full mmon on Wed Jan 03 21:26:03 JST 2007
full mmon on Fri Feb 02 09:54:51 JST 2007
full mmon on Sat Mar 03 22:23:39 JST 2007
full mmon on Mon Apr 02 10:52:27 JST 2007
full mmon on Tue May 01 23:21:15 JST 2007
full mmon on Thu May 31 11:50:03 JST 2007
full mmon on Sat Jun 30 00:18:51 JST 2007
full mmon on Sun Jul 29 12:47:39 JST 2007
full mmon on Tue Aug 28 01:16:27 JST 2007
full mmon on Wed Sep 26 13:45:15 JST 2007
full mmon on Fri Oct 26 02:14:03 JST 2007
full mmon on Sat Nov 24 14:42:51 JST 2007
full mmon on Mon Dec 24 03:11:39 JST 2007
full mmon on Tue Jan 22 15:40:27 JST 2008
full mmon on Thu Feb 21 04:09:15 JST 2008
full mmon on Fri Mar 21 16:38:03 JST 2008
full mmon on Sun Apr 20 05:06:51 JST 2008
full mmon on Mon May 19 17:35:39 JST 2008
full mmon on Wed Jun 18 06:04:27 JST 2008
full mmon on Thu Jul 17 18:33:15 JST 2008
full mmon on Sat Aug 16 07:02:03 JST 2008
full mmon on Sun Sep 14 19:30:51 JST 2008
full mmon on Tue Oct 14 07:59:39 JST 2008
full mmon on Wed Nov 12 20:28:27 JST 2008
$

0 コメント:

コメントを投稿