java -- 内部类

package sad;


public class ers {

public static void main(String[] args) {
RedCowForm a = new RedCowForm();
RedCowForm b = new RedCowForm("红牛");
b.ShowCow();
}}
class RedCowForm
{
String name;
RedCow cow;
RedCowForm()
{
System.out.println("输入错误");
}
RedCowForm(String s)
{
cow = new RedCow(100,100,200);
name = s;
}
class RedCow
{
int height;
int weight;
int price;
RedCow(int h,int w,int p)
{
height = h;
weight = w;
price = p;
}
void ShowMess()
{
System.out.println("height:"+height+"weight:"+weight+"price:"+price);
}
}
void ShowCow()
{
cow.ShowMess();
}
}

posted on 2017-09-03 00:28  qzb!!!  阅读(148)  评论(0编辑  收藏  举报

导航