• 第十一次 判断是否同一个人


    public class Shiyi {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            new Shiyi().fun();
        }
        public void fun()
        {
            System.out.println("Hello World!!!");
        }
    }









    public class Shier {
        String name;int age;
        public Shier(String name,int age) {
            this.name = name;
            this.age = age;
        }
        public boolean compare(Shier per) {
            if(this == per) {//地址相等
                return true;
            }
            if(this.name.equals(per.name) && this.age == per.age) {
                return true;
            }else {
                return false;
            }
        }
        public String getName() {
            return this.name;
        }
        public int getAge() {
            return this.age;
        }
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            Shier per1 = new Shier("xy",20);
            Shier per2 = new Shier("xy",20);
            if(per1.compare(per2)){
                System.out.println("这俩人一个样~");
            }
        }
    }




    public class Shisan {
        String name;int age;
        public Shisan(String name,int age) {
            this.name = name;
            this.age = age;
        }
        public boolean compare(Shisan per) {
            if(this.name.equals(per.name) && this.age == per.age) {
                return true;
            }else {
                return false;
            }
        }
        public String getName() {
            return this.name;
        }
        public int getAge() {
            return this.age;
        }
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            Shisan per1 = new Shisan("xy",20);
            Shisan per2 = new Shisan("xy",20);
            if(per1.compare(per2)){
                System.out.println("这俩人是同一个~");
            }
        }
    }




        class Person {
        private String name;
        private int age;
        public Person(String name,int age) {
            this.name = name;
            this.age = age;
        }
        public void fun(Person temp) {
            temp.name = "ktt";
            temp.age = 18;
        }
        public String getName() {
            return this.name;
        }
        public int getAge() {
            return this.age;
        }
    public static class Shisi {
        public static void main(String args[]) {
            // TODO Auto-generated method stub
            Person per = new Person("xy",20);
            per.fun(per);
            System.out.println(per.getName() + "-->" + per.getAge());
            }
        }
    }





    class Pe {
        private String name;
        private int age;
        public Pe(String name,int age) {
           this.name = name;
           this.age = age;
       }
       public String getName() {
           return this.name;
       }
       public int getAge() {
           return this.age;
       }
    }
    public  class Shiwu {
       public void main(String args[]) {
           Pe per1 = new Pe("xy",20);
           Pe per2 = new Pe("xy",20);
           if(per1.getName().equals(per2.getName())&&per1.getAge()==per2.getAge()) {
               System.out.println("这两人是一个样~");
           }
       }
    }
    
    
    
    
  • 相关阅读:
    Daily Scrumming* 2015.12.19(Day 11)
    Daily Scrumming* 2015.12.18(Day 10)
    软件工程 个人作业1
    网络1711-12&信管1711-12 图 作业评分
    网络1711-12 数据结构第一次作业评分
    Java课程设计
    网络1711-1712班 c 语言评分总表一览
    网络1711班 C语言第八次作业批改总结
    201621123050 《Java程序设计》第14周学习总结
    201621123050 《Java程序设计》第13周学习总结
  • 原文地址:https://www.cnblogs.com/jingjing1314/p/7865887.html
Copyright © 2020-2023  润新知