抽象类和接口
1、抽象类
抽象类中有抽象方法,也可以有其他方法。抽象类必须被继承才能使用。
2、接口
接口中只有抽象方法。
抽象方法必须在子类中重写
八大基本数据类型的包装类
short Short
int Integer
long Long
float Float
double Double
byte Byte
char Character
斗地主代码
package com.lzfthh;
import java.util.ArrayList;
import java.util.Random;
public class test {
public String poker(int num ){
String str;
String[] kind={"红桃","黑桃","方块","梅花"};
String[] number={"A","2","3","4","5","6","7","8","9","10","J","Q","K"};
if(num/4<=12){
str=kind[num%4]+number[num/4];
}else {
if(num%4==0){
str="大王";
}else {
str="小王";
}
}
return str;
}
public void pokerList(){
test p=new test();
ArrayList list=new ArrayList();
for (int i = 0; i < 54; i++) {
list.add(p.poker(i));
}
int length = list.size();
int count=0;
for (int i = 0; i <length ; i++) {
int num=new Random().nextInt(list.size());
System.out.print(list.get(num)+"\t");
list.remove(num);
count++;
if(count%17==0){
System.out.println();
}
}
}
public static void main(String[] args) {
test p=new test();
p.pokerList();
}
}