[AppleScript] 纯文本查看 复制代码
public class StrongTest2 {
public static void main(String[] args) {
Map<String, Integer> map = new HashMap<>();
map.put("13265477888", 168);
map.put("15241698745", 11);
map.put("13699989898", 20);
map.put("1898686666", 120);
for (String str : map.keySet()) {
System.out.println(str + "=" + map.get(str));
}
stdb db = null;
try {
db = new stdb("admin","123456");
}catch(Exception e) {
db = null;
e.printStackTrace();
}
String key = "15241698745";
if(db != null) {
if(db.getMap().containsKey(key)) {
System.out.println("该主机已登录");
}else {
db.getMap().put(key, map.get(key));
}
}
System.out.println("数据库中存在以下号码套餐");
for(String str :db.getMap().keySet()) {
System.out.println(str + "=" + db.getMap().get(str));
}
}
}
// 模拟数据库
class stdb {
private static Map<String, Integer> map = new HashMap<>();// 模拟numinfo表
public static final String username = "admin";
public static final String password = "123456";
public Map<String,Integer> getMap() {
map.put("13265477888", 168);
return map;
}
public static String getUsername() {
return username;
}
public static String getPassword() {
return password;
}
public stdb(String un, String pw) throws Exception {
if(!username.equals(un) || !password.equals(pw)) {
System.out.println("用户名或密码输入错误");
throw new Exception("用户名或密码输入错误");
}
}
private stdb() {}
}