public static void main(String[] args) {
// 权限
// 删除A---0
// 修改A---1
// 添加A---2
// 删除B---3
// 修改B---4
// 添加B---5
// purview是计算权限的总和
int purview = (int) Math.pow(2, 2) + (int) Math.pow(2, 3)
+ (int) Math.pow(2, 4);
// purviewValue是计算含有什么权限
int purviewValue = 2;
if(checkPower(purview, purviewValue)){
System.out.println("该用户权限符合");
}else{
System.out.println("该用户权限不符合");
}
}
public static boolean checkPower(int userPurview, int optPurview) {
int purviewValue = (int) Math.pow(2, optPurview);
return (userPurview & purviewValue) == purviewValue;
}