谁能帮忙补充完整下列JAVA程序代码?

来源:百度知道 编辑:UC知道 时间:2024/06/07 07:42:31
class A
{
//声明一个float型实例变量a
//声明一个float型类变量b,即static变量b
void setA(float a)
{
//将参数a的值赋值给成员变量a

}
void setB(float b)
{
//将参数b的值赋值给成员变量b
}
float getA()
{
return a;
}
float getB()
{
return b;
}
void inputA()
{
System.out.println(a);
}
static void inputB()
{
System.out.println(b);
}
}
public class Example
{
public static void main(String args[])
{
//通过类名操作类变量b,并赋值100
//通过类名调用方法inputB()
A cat=new A();
A dog=new A();
//cat调用方法setA(int a)将cat的成员 a的值设置为200
// cat调用方法setB(int B)将cat的成员 b的值设置400
//dog调用方法setA(int a)将dog的成员 a的值设置为150 //dog调用方法setB(int b)将dog的成员 b的值设置为300
//cat调用inputA()
//cat调用inputB()
//dog调用inputA

class A
{
//声明一个float型实例变量a
//声明一个float型类变量b,即static变量b
private float a;
private static float b;
void setA(float a)
{
//将参数a的值赋值给成员变量a
this.a = a;

}
void setB(float b)
{
//将参数b的值赋值给成员变量b
this.b = b;
}
float getA()
{
return a;
}
float getB()
{
return b;
}
void inputA()
{
System.out.println(a);
}
static void inputB()
{
System.out.println(b);
}
}
public class Example
{
public static void main(String args[])
{
//通过类名操作类变量b,并赋值100
//通过类名调用方法inputB()
A.b = 100;
A.inoutB();

A cat=new A();
A dog=new A();
//cat调用方法setA(int a)将cat的成员 a的值设置为200
cat.setA(200);
// cat调用方法setB(int B)将cat的成员 b的值设置400
cat.setB(400);
//dog调用方法setA(int a)将dog的成员 a的值设置为150
dog.setA(150);
//dog调用方法setB(int b)将dog的成员 b的值设置为300
dog.setB(300);
//cat调用input