person s1=new student("lili",13,"china",88);
person s2=new student("wuwu",12,"china",85);
person s3=new student("zzww",15,"english",78);
person s4=new student("xiaoxiao",16,"china",66);
person s5=new student("xiaoli",11,"china",95);
person t1=new teacher("bigbig",35,"english",5000);
person t2=new teacher("biga",33,"china",3000);
person t3=new teacher("bigb",36,"china",5500);
person t4=new teacher("bigc",31,"china",7500);
person t5=new teacher("bigd",37,"china",6000);
public String show()
{
return super.basicinfo()+",my is a teacher,my pay is "+this.pay;
}
}
以下是common类内容:
package javatest1;
import java.util.ArrayList;
import java.util.List;
class swapobj<E>
{
E swapvalue;
}
public class common {
//简单打印
public static <E> void print(E value)
{
System.out.println(value);
}
//字符串每个字符变成ascii码
public static StringBuilder stringchangeasc(String value)
{
char[] ca;
int cai;
StringBuilder sb=new StringBuilder();
ca = value.toCharArray(); //把传过来的value转换为字符数组
for(int i=0;i<ca.length;++i)
{
cai=ca[i];
//print(ca[i]+"的ascii码是"+cai);
sb.append(ca[i]+"的ascii码是"+cai);
sb.append("\n");
}
return sb;
}
//如果输出内容是不同部分的话,用************************************隔开
public static void printseparator()
{
print("************************************");
}
//字符串中每一个字符串大写变小写,小写变大与,如果不是字母的话不改变
public static StringBuilder stringchangcw(String value)
{
int cai = 0;
char[] ca;
List cb=new ArrayList();
StringBuilder sb=new StringBuilder();
ca = value.toCharArray();
for(int i=0;i<ca.length;++i)
{
if(ca[i]>65 && ca[i]<90)
{
cai=ca[i]+32;
}
else
if(ca[i]>97 && ca[i]<122)
{
cai=ca[i]-32;
}
else
{
cai=ca[i];
}
//cai=ca[i]+32;
cb.add(cai);
}
for(int j=0;j<cb.size();++j)
{
int obji=(int) cb.get(j);
char oi=(char)obji;
sb.append(oi);
}
return sb;
}
//对传过来的值相加,得到传过来的值的和,传过来的参数个数不限,喜欢多少个参数都可以
public static int argadd(int... arg){
int sum = 0,len=arg.length;
for(int i=0;i<len;++i){
sum=sum+arg[i];
}
return sum;
}
//对传过来的值找出最大值,传过来的参数个数不限,喜欢多少个参数都可以
public static int argmax(int... arg){
int max = arg[0],len=arg.length;
for(int i=1;i<len;++i){
if(max<arg[i])
{
max=arg[i];
}
}
return max;
}
/*public static <E> E argmax(E... arg){
E max = arg[0];
int len=arg.length;
for(int i=1;i<len;++i){
if(max<arg[i])
{
max=arg[i];
}
}
return max;
}*/
//对传过来的值找出最小值,传过来的参数个数不限,喜欢多少个参数都可以
public static int argmin(int... arg){
int min = arg[0],len=arg.length;
for(int i=1;i<len;++i){
if(min>arg[i])
{
min=arg[i];
}
}
return min;
}