1、 people package 中的 people.java
package people;
import dog.dog;
public class people {
int eves = 2;
public int hand = 2;
int blood =100;
public int heartBit = 60;
String color = "黄皮肤";
public String name;
public int sing(String name){
heartBit++;
return hand;
}
public dog dog;
public void hit(dog dog){
}
}
2、dog package 中的 dog.java
package dog;
import people.people;
public class dog {
int leg = 4;
int ear = 2;
public String name;
public String color;
public void bite(people people){
System.out.println("狗咬了"+ people.name +"的手。");
people.hand = people.hand - 1;
System.out.println(people.name +"的手还剩"+ people.hand +"只。");
}
}
3、start package 中的 start.java
package sum;
import dog.dog;
import people.people;
public class start {
public static void main(String[] agrs){
people my = new people();
my.name = "马云";
people hz = new people();
hz.name = "黄章";
people lj = new people();
lj.name = "雷军";
dog kk = new dog();
kk.name = "卡卡";
my.dog = kk;
kk.bite(my);
}
}