日期:2014-05-20 浏览次数:20939 次
    private CommunityEntity[] commArr;
    public DbStore() //初始化用户实体数组
    {
        CommunityEntity com1 = new CommunityEntity();
        com1.setCommId("001");
        com1.setCommName("新升新苑");
        com1.setCommManager("大漠");
        com1.setCommArea("高新区");
        com1.setCommStatue("可放装");
        com1.setPermeability(61);
        com1.setUserCount(221);
        
        CommunityEntity com2 = new CommunityEntity();
        com2.setCommId("002");
        com2.setCommName("新盛花园");
        com2.setCommManager("大漠");
        com2.setCommArea("吴中区");
        com2.setCommStatue("可放装");
        com2.setPermeability(62);
        com2.setUserCount(222);
        
        CommunityEntity com3 = new CommunityEntity();
        com3.setCommId("003");
        com3.setCommName("新唯家园");
        com3.setCommManager("大漠");
        com3.setCommArea("工业园区");
        com3.setCommStatue("可放装");
        com3.setPermeability(63);
        com3.setUserCount(223);
        
        CommunityEntity com4 = new CommunityEntity();
        com4.setCommId("004");
        com4.setCommName("蠡东花园");
        com4.setCommManager("大漠");
        com4.setCommArea("相城区");
        com4.setCommStatue("可放装");
        com4.setPermeability(64);
        com4.setUserCount(224);
        
        CommunityEntity com5 = new CommunityEntity();
        com5.setCommId("005");
        com5.setCommName("朱家庄新村");
        com5.setCommManager("大漠");
        com5.setCommArea("金阊区");
        com5.setCommStatue("可放装");
        com5.setPermeability(65);
        com5.setUserCount(225);
         setCommArr(new CommunityEntity[]{com1,com2,com3,com4,com5});
    }
    public void setCommArr(CommunityEntity[] commArr) 
    {
        this.commArr = commArr;
    }
    public CommunityEntity[] getCommArr()
    {
        return commArr;
    }
        
import java.util.Scanner;
import User.DbStore;
public class CommunityManager 
{
    public static void main(String args[])
    {
        delete();
    }
    public static void delete()
    {
        DbStore abcd = new DbStore();
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入要删除的社区编号");
        String deletingId = scan.next();
        boolean judge = false;
        for(int i=0;i<abcd.getCommArr().length;i++)
        {
            if(abcd.getCommArr()[i].getCommId().equals(deletingId))
            {
                System.out.println("您要删除的社区编号是:"+deletingId);
                judge = true;
                break;
            }
        }
        if(!judge)
        {
            System.out.println("该社区不存在!");
        }
    }
}