Poker小游戏预备

目的:
1.回顾和掌握类的定义
2.对于static和private的更深层的理解
3.熟悉和掌握java类和方法的创建和调用
4.学习开发程序的思维
技术实施:
基本架构:

image.png

创建输出方法:

public class Utils {
    /**
     * 输出一行数据 不换行
     *  text
     */
    public static void showText(String text){
        System.out.print(text);
    }

    /**
     * 输出一行数据 换行
     *  text
     */
    public static void showTextln(String text){
        System.out.println(text);
    }

    /**
     * 输出一行数据 可以设置分隔符
     *  hasStar
     *  text
     */
    public static void showText(boolean hasStar, String text){
        if (hasStar){
            System.out.println("****************");
        }

        System.out.println(text);

        if (hasStar){
            System.out.println("****************");
        }
    }

    public static void showText(String... texts){
        System.out.println("****************");

        //1. 下注
        //自动给每个选项添加编号
        for(int i = 1; i <= texts.length; i++){
            String str = texts[i-1];
            System.out.println(i+". "+str);
        }

        System.out.println("****************");

    }
}

管理花色:

class PokerType{
    //黑桃的一个对象
    public static final PokerType SPADES = new PokerType("[图片上传失败...(image-a7051d-1565277094215)]

",4);
    //红桃
    public static final PokerType HEARTS = new PokerType("[图片上传失败...(image-ac9307-1565277094215)]

",3);
    //梅花
    public static final PokerType CLUBS = new PokerType("[图片上传失败...(image-a81dbc-1565277094215)]

",2);
    //方片
    public static final PokerType DIAMONDS = new PokerType("[图片上传失败...(image-9040fe-1565277094215)]

",1);

    public String pic; //记录图案
    public int id; //专门用于比较

    //构造方法
    public PokerType(String pic, int id){
        this.pic = pic;
        this.id = id;
    }
}

显示所有的牌:

    public void show(){
        for (Poker poker: pokers){
            System.out.print(poker.number+poker.type.pic + " ");
        }
    }

感受:
感觉这种带回顾的授课方式很好,给我带来更多知识的理解和消化。讲概念的东西枯燥是枯燥了点,但还是可以理解的,讲真的到实际应用的时候总是感觉知识拿不出来,不知道如何用。只能呆呆地听着,有点无力的感觉。还是坚持吧!

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 一. Java基础部分.................................................
    wy_sure阅读 9,229评论 0 11
  • 好久没有参加朋友的婚礼,这一年身边的朋友结婚,很多都因为距离的原因而缺席。今天朋友结婚,定了距离家特别近的一个酒店...
    优优和吖吖阅读 1,241评论 0 1
  • 在新单位上班已经一个多月了,在这段时间里,突然觉得自己就像一个傻子一样,根本不适合在职场。 作为处女座的自己,做事...
    歆弦阅读 3,499评论 0 1
  • 累惨了,还没加到几个资源啊啊啊,一天拖一天
    是小苗阅读 968评论 0 0