码迷,mamicode.com
首页 > 其他好文 > 详细

类与类包含关系,实例;

时间:2020-05-04 15:45:14      阅读:70      评论:0      收藏:0      [点我收藏+]

标签:main   圆形   构造   包含   highlight   spl   上海   png   alt   

//D:\java\object\Functions\include\Bike.java;
package include;

public class Wheel{
	public String color;
	public int size;
	public String lunzi;
	public Wheel(){
	}
	public Wheel(String color,int size,String lunzi){
		this.color=color;
		this.size=size;
		this.lunzi=lunzi;
	}//构造方法重载
	public void run(){
		System.out.println("随意方向旋转");
	}
}

 

//D:\java\object\Functions\include\Wheel.java;
package include;

public class Wheel{
	public String color;
	public int size;
	public String lunzi;
	public Wheel(){
	}
	public Wheel(String color,int size,String lunzi){
		this.color=color;
		this.size=size;
		this.lunzi=lunzi;
	}//构造方法重载
	public void run(){
		System.out.println("随意方向旋转");
	}
}

 

//D:\java\object\Functions\include\Test.java;
package include;

public class Test{
	public static void main(String[] args){
		/*
		Bike a=new Bike();
		a.color="黑色";
		a.brand="凤凰牌";
		a.type="24式";
		a.lee=new Wheel();
		a.lee.color="黄色";
		a.lee.size=240;
		a.lee.lunzi="圆形";
		a.display();	
		*/  
				
		Bike c=new Bike("上海牌","红色","14寸",new Wheel("黑色",140,"圆环形"));		
		c.display();
	
		
	}
}

  技术图片

 技术图片

 

 

 

 

 

类与类包含关系,实例;

标签:main   圆形   构造   包含   highlight   spl   上海   png   alt   

原文地址:https://www.cnblogs.com/canglongdao/p/12826513.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!