本帖最后由 不死猫 于 2012-8-5 11:06 编辑
20120727 连续下雨4天
对象数组 内部类
系统登录看过一遍后自己再模仿写一个
- public class Test {
- public static void main(String[] args)
- {
- Operate op = new Operate(args);
- System.out.print(op.刷卡());
- }
- }
- class Check{
- private boolean pass;
- public Check(String name,String password){
- if (name.equals("不死猫")&&password.equals("nonsmall")){
- pass= true;
- }else{
- pass=false;
- }
- }
- public boolean check(){
- return pass;
- }
- }
- class Operate{
- String info[];
- String str,name,password;
- public Operate(String info[]){
- this.info = info;
- isExit();
- }
- public String 刷卡(){
- name = info[0];
- password = info[1];
- Check it = new Check(name,password);
- if (it.check()){
- str = "登陆成功";
- }else{
- str="密码错误";
- }
- return str;
- }
- private void isExit(){
- if (info.length != 2){
- System.out.print("输入错误");
- System.exit(1);
- }
- }
- }
|