

java初心者です。  
以前投稿していたのを削除し改めてコードを書き直しアプリケーションを作成しているのですが、初の自作アプリが上手くつくれません。  
コンセプトはゲームのアクションの技でどの組み合わせが一番ダメージをだせるかとうものです。

まだ作成段階ですがコードは

[code]

    class Act{
        public static void main(String args[]){
                ActDmgTotalReject act = new ActDmgTotalReject();
                act.ActDmgTotal();
        }
    }
    class ActDmgSrc{
    
        static double ruin[] = {2.50,   2.50,  80,   53,         0};
                //ActionSkillの{cast, recast, dmg, cost   dmg_time};
        static double baio[] = {  0,   2.50,  40,   110,       18};
    
    }
    class ActDmgTotalReject extends ActDmgSrc{
        void ActDmgTotal(){
            double count = 240; //処理回数を数えて、２４０こえたらループを終わらせる関数
            double total = 0; //ダメージの総ダメージ
            double ruin_count = 0;//ruinの数
            double baio_count = 0;//baioの数
            double dmg_ruin = 0;//ruinのダメージ
            double dmg_baio = 0;//baioのダメージ
            if(count <= 240  ){
                for(;ruin_count <= 240; ruin_count++){
                    baio_count =((count - ruin_count * ActDmgSrc.ruin[1])
                            / ActDmgSrc.baio[1]);
                    if(baio_count >=0){
                        System.out.println("ruin_count = " + ruin_count);
                        System.out.println("baio_count = " + baio_count);
                        dmg_ruin = ActDmgSrc.ruin[2]* ruin_count;//ruinのダメージ計算
                        dmg_baio = ActDmgSrc.baio[2]* baio_count
                                +ActDmgSrc. baio[2]*(ActDmgSrc.baio[4] / 3);//baioのダメージ計算
                        total = dmg_ruin+ dmg_baio;
                        System.out.println("total = " + total);
                    }
                }
            }
    
        }
    }
    
[/code]

です。  
４分間で最大のダメージを出す組み合わせを求めるということでまずcountを240としcountが240になったら計算を終わりという式にしました（そのつもりです）  
そしてruin_countとbaio_countでその技の回数と場合分けを全部だしました。  
その使用回数とダメージを掛けて組み合わせに対する総ダメージを求めたいのですが  
baioというのが18秒間自動で40のダメージを出していてその間も他の技が打てるということを上手くコードでかけませんでした。またruin_countとbaio_countの組み合わせはいいのですがダメージの値がおかしいです。

[code]

    ruin_count = 0.0
    baio_count = 96.0
    total = 4080.0
    ruin_count = 1.0
    baio_count = 95.0
    total = 4120.0
    ruin_count = 2.0
    baio_count = 94.0
    total = 4160.0
    ruin_count = 3.0
    baio_count = 93.0
    total = 4200.0
    ruin_count = 4.0
    baio_count = 92.0
    total = 4240.0
    ruin_count = 5.0
    baio_count = 91.0
    total = 4280.0
    ruin_count = 6.0
    baio_count = 90.0
    total = 4320.0
    ruin_count = 7.0
    baio_count = 89.0
    total = 4360.0
    ruin_count = 8.0
    baio_count = 88.0
    total = 4400.0
    ruin_count = 9.0
    baio_count = 87.0
    total = 4440.0
    ruin_count = 10.0
    baio_count = 86.0
    total = 4480.0
    ruin_count = 11.0
    baio_count = 85.0
    total = 4520.0
    ruin_count = 12.0
    baio_count = 84.0
    total = 4560.0
    ruin_count = 13.0
    baio_count = 83.0
    total = 4600.0
    ruin_count = 14.0
    baio_count = 82.0
    total = 4640.0
    ruin_count = 15.0
    baio_count = 81.0
    total = 4680.0
    ruin_count = 16.0
    baio_count = 80.0
    total = 4720.0
    ruin_count = 17.0
    baio_count = 79.0
    total = 4760.0
    ruin_count = 18.0
    baio_count = 78.0
    total = 4800.0
    ruin_count = 19.0
    baio_count = 77.0
    total = 4840.0
    ruin_count = 20.0
    baio_count = 76.0
    total = 4880.0
    ruin_count = 21.0
    baio_count = 75.0
    total = 4920.0
    ruin_count = 22.0
    baio_count = 74.0
    total = 4960.0
    ruin_count = 23.0
    baio_count = 73.0
    total = 5000.0
    ruin_count = 24.0
    baio_count = 72.0
    total = 5040.0
    ruin_count = 25.0
    baio_count = 71.0
    total = 5080.0
    ruin_count = 26.0
    baio_count = 70.0
    total = 5120.0
    ruin_count = 27.0
    baio_count = 69.0
    total = 5160.0
    ruin_count = 28.0
    baio_count = 68.0
    total = 5200.0
    ruin_count = 29.0
    baio_count = 67.0
    total = 5240.0
    ruin_count = 30.0
    baio_count = 66.0
    total = 5280.0
    ruin_count = 31.0
    baio_count = 65.0
    total = 5320.0
    ruin_count = 32.0
    baio_count = 64.0
    total = 5360.0
    ruin_count = 33.0
    baio_count = 63.0
    total = 5400.0
    ruin_count = 34.0
    baio_count = 62.0
    total = 5440.0
    ruin_count = 35.0
    baio_count = 61.0
    total = 5480.0
    ruin_count = 36.0
    baio_count = 60.0
    total = 5520.0
    ruin_count = 37.0
    baio_count = 59.0
    total = 5560.0
    ruin_count = 38.0
    baio_count = 58.0
    total = 5600.0
    ruin_count = 39.0
    baio_count = 57.0
    total = 5640.0
    ruin_count = 40.0
    baio_count = 56.0
    total = 5680.0
    ruin_count = 41.0
    baio_count = 55.0
    total = 5720.0
    ruin_count = 42.0
    baio_count = 54.0
    total = 5760.0
    ruin_count = 43.0
    baio_count = 53.0
    total = 5800.0
    ruin_count = 44.0
    baio_count = 52.0
    total = 5840.0
    ruin_count = 45.0
    baio_count = 51.0
    total = 5880.0
    ruin_count = 46.0
    baio_count = 50.0
    total = 5920.0
    ruin_count = 47.0
    baio_count = 49.0
    total = 5960.0
    ruin_count = 48.0
    baio_count = 48.0
    total = 6000.0
    ruin_count = 49.0
    baio_count = 47.0
    total = 6040.0
    ruin_count = 50.0
    baio_count = 46.0
    total = 6080.0
    ruin_count = 51.0
    baio_count = 45.0
    total = 6120.0
    ruin_count = 52.0
    baio_count = 44.0
    total = 6160.0
    ruin_count = 53.0
    baio_count = 43.0
    total = 6200.0
    ruin_count = 54.0
    baio_count = 42.0
    total = 6240.0
    ruin_count = 55.0
    baio_count = 41.0
    total = 6280.0
    ruin_count = 56.0
    baio_count = 40.0
    total = 6320.0
    ruin_count = 57.0
    baio_count = 39.0
    total = 6360.0
    ruin_count = 58.0
    baio_count = 38.0
    total = 6400.0
    ruin_count = 59.0
    baio_count = 37.0
    total = 6440.0
    ruin_count = 60.0
    baio_count = 36.0
    total = 6480.0
    ruin_count = 61.0
    baio_count = 35.0
    total = 6520.0
    ruin_count = 62.0
    baio_count = 34.0
    total = 6560.0
    ruin_count = 63.0
    baio_count = 33.0
    total = 6600.0
    ruin_count = 64.0
    baio_count = 32.0
    total = 6640.0
    ruin_count = 65.0
    baio_count = 31.0
    total = 6680.0
    ruin_count = 66.0
    baio_count = 30.0
    total = 6720.0
    ruin_count = 67.0
    baio_count = 29.0
    total = 6760.0
    ruin_count = 68.0
    baio_count = 28.0
    total = 6800.0
    ruin_count = 69.0
    baio_count = 27.0
    total = 6840.0
    ruin_count = 70.0
    baio_count = 26.0
    total = 6880.0
    ruin_count = 71.0
    baio_count = 25.0
    total = 6920.0
    ruin_count = 72.0
    baio_count = 24.0
    total = 6960.0
    ruin_count = 73.0
    baio_count = 23.0
    total = 7000.0
    ruin_count = 74.0
    baio_count = 22.0
    total = 7040.0
    ruin_count = 75.0
    baio_count = 21.0
    total = 7080.0
    ruin_count = 76.0
    baio_count = 20.0
    total = 7120.0
    ruin_count = 77.0
    baio_count = 19.0
    total = 7160.0
    ruin_count = 78.0
    baio_count = 18.0
    total = 7200.0
    ruin_count = 79.0
    baio_count = 17.0
    total = 7240.0
    ruin_count = 80.0
    baio_count = 16.0
    total = 7280.0
    ruin_count = 81.0
    baio_count = 15.0
    total = 7320.0
    ruin_count = 82.0
    baio_count = 14.0
    total = 7360.0
    ruin_count = 83.0
    baio_count = 13.0
    total = 7400.0
    ruin_count = 84.0
    baio_count = 12.0
    total = 7440.0
    ruin_count = 85.0
    baio_count = 11.0
    total = 7480.0
    ruin_count = 86.0
    baio_count = 10.0
    total = 7520.0
    ruin_count = 87.0
    baio_count = 9.0
    total = 7560.0
    ruin_count = 88.0
    baio_count = 8.0
    total = 7600.0
    ruin_count = 89.0
    baio_count = 7.0
    total = 7640.0
    ruin_count = 90.0
    baio_count = 6.0
    total = 7680.0
    ruin_count = 91.0
    baio_count = 5.0
    total = 7720.0
    ruin_count = 92.0
    baio_count = 4.0
    total = 7760.0
    ruin_count = 93.0
    baio_count = 3.0
    total = 7800.0
    ruin_count = 94.0
    baio_count = 2.0
    total = 7840.0
    ruin_count = 95.0
    baio_count = 1.0
    total = 7880.0
    ruin_count = 96.0
    baio_count = 0.0
    total = 7920.0
    
[/code]

といった形になりbaioを一度もつかってない状態が一番ダメージをだしているという結果になってしまっています。  
独学で完成しても正しいかわかりませんが、初の試みなのでどうやって作成していくといいかもわかっていません。  
いずれもっと攻撃技を増やしていくことを考えるとこのコードの書き方だと難しいのではないかとも考えています。  
アクションの組み合わせとダメージの計算の仕方をご教授願いたいです。


CC BY-SA 3.0
2015-07-02T07:10:44.357
11952
2015-07-02T12:07:31.833
10197
question
java
javaで計算式が上手くいかない。


ご自身も書いていますが、costの概念が全くないので単純にダメージが大きい技？を繰り返し使えば最大値になるのごく当然でしょう。  
コストが時間経過とどう関係するのか決まれば、2つの不等式になるので、線形計画法という問題として解くことができます。


CC BY-SA 3.0
2015-07-02T12:07:31.833
11964
2015-07-02T12:07:31.833
8136
11952
answer