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