Java Enum类型定义的方法(二)

package com.abin.info.service;

public interface TeamService {

public static enum TeamType {
TeamName("NameOfTeam"), TeamNumber("NumberOfTeam"), TeamArea(
"AreaOfTeam"), TeamTrue("TrueOfTeam"), TeamFalse("FalseOfTeam"), TeamInitialize(
"InitializeOfTeam");

private String TeamInfo;

private TeamType(String _TeamInfo) {
this.TeamInfo = _TeamInfo;
}

public String toString() {
return TeamInfo;
}

}

int compare(TeamType obj);

String insert(TeamType obj);
}








package com.abin.info.service;

public class TeamServiceImpl implements TeamService{
private TeamType type=TeamType.TeamInitialize;
public int compare(TeamType obj) {
System.out.println(type.toString());
if(obj.equals(TeamType.TeamNumber)){
return 1;
}
return 0;
}

public String insert(TeamType obj) {
System.out.println(type.toString());
if(obj.equals(TeamType.TeamArea)){
return "area";
}
return "notarea";
}


}










package com.abin.inter.test;

import junit.framework.TestCase;

import com.abin.info.service.TeamService;
import com.abin.info.service.TeamServiceImpl;
import com.abin.info.service.TeamService.TeamType;

public class TestTeam extends TestCase{

public void test(){
TeamType team=TeamType.TeamNumber;
TeamService service=new TeamServiceImpl();
int result=service.compare(team);
assertEquals(1, result);
System.out.println("compare 's result="+result);

TeamType team1=TeamType.TeamArea;
TeamService service1=new TeamServiceImpl();
String result1=service1.insert(team1);
assertEquals("area",result1);
System.out.println("insert 's result="+result1);
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值