⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sample.java

📁 JAVA程序设计课程中各章节的程序实例。
💻 JAVA
字号:
//Sample2004.10.22
class Box
{
	double width;
	double height;
	double depth;

	Box()
	{
		width = height = depth = -1;
	}

	Box(double len)
	{
		width = height = depth = len;
	}

	Box(double w, double h, double d)
	{
		width = w;
		height = h;
		depth = d;
	}

	double volume()
	{
		return width*height*depth;
	}
}

class boxWeight extends Box
{
	double weight;

	boxWeight(double w, double h, double d, double wh)
	{
		width = w;
		height = h;
		depth = d;
		weight = wh;
	}
	double volume()
	{
		return width*height*depth*weight;
	}
}

class Sample
{
	public static void main(String args[])
	{
		boxWeight mybox1 = new boxWeight(10,11,12,13);
		double vol;

		vol = mybox1.volume();
		System.out.println(vol);
		System.out.println("result:"+10*11*12*13);
		System.out.println("result="+5+6);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -