day07(面向对象)
2016-09-09 本文已影响0人
Honour_Lee
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);
}
//汉诺塔问题
//斐波那契数列
}