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

📄 example4_9.java

📁 java练习程序
💻 JAVA
字号:
import java.applet.*;
import java.awt.*;
interface Computable
{
	final int mymax=100;
	void speak(String s);
	int f(int x);
	float g(float x,float y);
}

class Chinese implements Computable
{
	int xuehao;
	public int f(int x)
	{
		int sum=0;
		for(int i=1;i<=x;i++)
		{
			sum+=i;
		}
		return sum;
	}
	public float g(float x,float y)
	{
		return 6;
	}
	public void speak(String s)
	{
	}
}

class Japanese implements Computable
{
	int xuehao;
	public int f(int x)
	{
		return 68;
	}
	public float g(float x,float y)
	{
		return x+y;
	}
	public void speak(String s)
	{
	}
}		

public class example4_9 extends Applet
{
	Chinese Li;
	Japanese Henlu;
	public void init()
	{
		Li=new Chinese();
		Henlu=new Japanese();
		Li.xuehao=991898;
		Henlu.xuehao=941444;
	}
	public void paint(Graphics g)
	{
		g.drawString("学号:"+Li.mymax+Li.xuehao+"从1到100求和"+Li.f(100),10,20);
		g.drawString("学号:"+Henlu.mymax+Henlu.xuehao+"加法"+Henlu.g(2.0f,3.0f),10,40);
	}
}

⌨️ 快捷键说明

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