目的:
1.回顧和掌握類的定義
2.對于static和private的更深層的理解
3.熟悉和掌握java類和方法的創(chuàng)建和調(diào)用
4.學(xué)習(xí)開發(fā)程序的思維
技術(shù)實施:
基本架構(gòu):
image.png
創(chuàng)建輸出方法:
public class Utils {
/**
* 輸出一行數(shù)據(jù) 不換行
* text
*/
public static void showText(String text){
System.out.print(text);
}
/**
* 輸出一行數(shù)據(jù) 換行
* text
*/
public static void showTextln(String text){
System.out.println(text);
}
/**
* 輸出一行數(shù)據(jù) 可以設(shè)置分隔符
* 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; //專門用于比較
//構(gòu)造方法
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 + " ");
}
}
感受:
感覺這種帶回顧的授課方式很好杨名,給我?guī)砀嘀R的理解和消化蜕提。講概念的東西枯燥是枯燥了點,但還是可以理解的,講真的到實際應(yīng)用的時候總是感覺知識拿不出來,不知道如何用。只能呆呆地聽著,有點無力的感覺。還是堅持吧募胃!