美文网首页
day07(面向对象)

day07(面向对象)

作者: Honour_Lee | 来源:发表于2016-09-09 22:51 被阅读0次

    Person类:
    public class Person {
    private String name;
    private int age;
    private double height;
    private double weight;
    private boolean married;

    public int getAge()
    {
        return age;
    }
    public void setAge(int age)
    {
        this.age = age;
    }
    
    public void setMarried(boolean married)
    {
        this.married = married;  
    }
    public boolean isMarried()
    {
        return this.married;
    }
    
    
    void drink()
    {
    
    }
    public void drink(int a)
    {
    
    }
    public void drink(int a,int b)
    {
    
    }
    public void drink(int a,double c)
    {
    
    }
    
    public Person()
    {
        
    }
    public Person(int age,String name)
    {
        this.age = age;
        this.name = name;
    

    // this.weight = weight;
    // this.height = height;
    }
    public Person(int age ,String name, double weight, double height)
    {
    this.age = age;
    this.name = name;
    this.weight = weight;
    this.height = height;
    }

    public static void main(String[] args) {
        Person tmpPerson = new Person();
        Person tmpPerson1 = new Person(10,"make",1.0,1.0);
        
        tmpPerson.age = 10;
    }
    

    }

    Human类:
    public class Humen {
    public static void main(String[] args) {

        Person p = new Person();
        Person p1 = new Person(11,"dfa",14.3,90.2);
        Person p2 = new Person(11,"rwe");
    }
    

    }

    递归:

    public class Test01 {
    public static void main(String[] args) {

    // someMethod();
    otherMethod(1);

    }
    public static void someMethod()
    {
        someMethod();
        System.out.println("递归");
    }
    
    public static void otherMethod(int i) {
        if(i < 0)
        {
            System.out.println("结束");
        }
        else
        {
            System.out.println("qqq"+i);
            otherMethod(--i);
            System.out.println("ddd"+i);
    

    // System.out.println(i);
    }
    System.out.println(i);
    }
    //汉诺塔问题
    //斐波那契数列
    }

    相关文章

      网友评论

          本文标题:day07(面向对象)

          本文链接:https://www.haomeiwen.com/subject/fncyettx.html