package example7_1;
public class RedCowFarm {
static String farmName;
RedCow cow;
RedCowFarm(){
}
RedCowFarm(String s){
cow=new RedCow(150,112,6000);
farmName=s;
}
public void showCowMess(){
cow.speak();
}
static class RedCow{
String cowName="红牛";
int height,weight,price;
RedCow(int h,int w,int p){
height=h;
weight=w;
price=p;
}
void speak(){
System.out.println("我"+cowName+"身高"+height+"体重"+weight+"生活"+farmName) ;
}
}
}
package example7_1;
public class example7_1 {
public static void main(String args[]){
RedCowFarm farm= new RedCowFarm("红牛农场");
farm.showCowMess();
farm.cow.speak();
RedCowFarm.RedCow redcow=new RedCowFarm.RedCow(177,234,1342);
redcow.speak();
}
}