1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Money.java
package LifeGame;

class Money {

    /*
     * Moneyクラスは各イベントによって賞金や所持金の増減が決まるので
     * 固有値は定義しません。
     * イベントクラスでそれぞれ定義してください。
     *
     * */


    //所持金変数
    private int myMoney;
    //論理値
    private boolean logic;

    //所持金セットゲット
    public int getMyMoney() {
        return myMoney;
    }

    public void setMyMoney1(int myMoney) {
        this.myMoney = myMoney;
    }

    //所持金増減セッター
    public void setMyMoney2(int myMoney) {
        if(getMyMoney() > Constant.MAXMONEY) {
            //所持金が上限値を超えたら所持金に上限値を代入
            setMyMoney1(Constant.MAXMONEY);
        }
        else if(getMyMoney() < Constant.MINMONEY) {
            //所持金が下限値を超えたら所持金に下限値を代入
            setMyMoney1(Constant.MINMONEY);
        }
        else {
            this.myMoney += myMoney;
        }
    }

    //論理値セットゲット
    public boolean getLogic() {
        return logic;
    }

    public void setLogic(boolean logic) {
        this.logic = logic;
    }

    //賞金メソッド
    public int prizeGet(int prize) {
        //各イベントごとに賞金の引数を定義し所持金に追加
        setMyMoney2(prize);
        return prize;
    }

    //所持金増減
    public void moneyVary(int vary) {
        if(getLogic() == true) {
            //論理値がtrueなら所持金増
            setMyMoney2(vary);
        }else {
            //論理値がfalseなら所持金減
            setMyMoney2(-vary);
        }
    }
}

0
oyoyo_oyoyo
@oyoyo_oyoyo
2020-02-06 10:59
Constant.java
package LifeGame;

public class Constant {
/*
*定数はこのクラスに追加してください
*/
    //所持金最大値
    static final int MAXMONEY = 999999999;

    //所持金最小値
    static final int MINMONEY = -999999999;
}


0
oyoyo_oyoyo
@oyoyo_oyoyo
2020-02-06 11:01
Character.java
package LifeGame;

public class Character {
    //名前
    private String name;
    //性別
    private boolean gender;
    //職業
    private String job;
    //年齢
    private int age;

    //プレイヤーナンバー
    public static int playerNum = 0;

    //セッターゲッター
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public boolean getGender() {
        return gender;
    }
    public void setGender(boolean gender) {
        this.gender = gender;
    }
    public String getJob() {
        return job;
    }
    public void setJob(String job) {
        this.job = job;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }

    //コンストラクタ
    public Character(String name) {
        //インスタンス化した順にplayerナンバーを決定
        playerNum += 1;
        setName(name);
        System.out.println("こんにちわ\n"+name+"さんはplayer"+playerNum+"です");
    }
}

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?