我的麻将类写对没?为啥跟别人的不一样?

package com.xiao.entity;

import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.ArrayList;

/**
 * @ClassName Mahjong
 * @Author: 肖遥
 * @Description 麻将类
 * @date 2022/5/14 16:58
 * @Version 1.0
 */

@Data
@NoArgsConstructor
public class Mahjong {

    private int order;
    private Owner owner;
    private Flower flower;
    private Num num;
    private State state;

    public Mahjong(int i, Owner owner, Flower flower, Num num, State state) {
        this.order = i;
        this.owner = owner;
        this.flower = flower;
        this.num = num;
        this.state = state;
        if (state.equals("海里")) {
            this.owner = Owner.USED;
        }
    }

    public Mahjong(Num num, Flower flower) {
        this.num = num;
        this.flower = flower;
    }


    public enum Owner {
        PLAYER1, PLAYER2, PLAYER3, PLAYER4, USED
    }

    public enum Flower {
        条, 饼, 万
    }

    public enum Num {
        一, 二, 三, 四, 五, 六, 七, 八, 九
    }

    public enum State {
        手牌, 列牌, 海里
    }

    @Override
    public String toString() {
        return "Mahjong{" +
                "NO." + order + "|持有人:" + owner + "|" + num + flower + "|状态:" + state +
                '}';
    }

    public static ArrayList<Mahjong> mahjongPairs() {

        ArrayList<Mahjong> mahjongS = new ArrayList<>();

        for (Flower flower : Flower.values()
        ) {
            for (Num num : Num.values()
            ) {
                for (int i = 0; i < 4; i++) {
                    Mahjong mahjong = new Mahjong(num, flower);
                    mahjongS.add(mahjong);
                }

            }
        }
        return mahjongS;
    }

}

  

posted @ 2022-05-14 19:53  风肖肖(肖遥)  阅读(20)  评论(0编辑  收藏  举报