早教吧作业答案频道 -->其他-->
定义一个类,该类具有x和y两个属性,定义构造函数初始化这两个属性.类中还定义以下方法:求两个数的和(x+y)并返回结果的方法,求两个数的差(x-y)并返回结果的方法,求两个数的乘(x*y)并返回结
题目详情
定义一个类,该类具有x和y两个属性,定义构造函数初始化这两个属性.类中还定义以下方法:求两个数的和(x+y)并返回结果的方法,求两个数的差(x-y)并返回结果的方法,求两个数的乘(x*y)并返回结果的方法,求两个数的商(x/y)并返回结果的方法,求两个数的余(x%y)并返回结果的方法,求两个数的最大值并返回结果的方法,求两个数的最小值并返回结果的方法
▼优质解答
答案和解析
public class ClsAAA
{
int x;
int y;
public int X
{
get{return x;}
set{x=value;}
}
public int Y
{
get{return y;}
set{y=value;}
}
public ClsAAA(){
x=0;
y=0;
}
public int GetSum(){
return X+Y;
}
public int GetDiff(){
return X-Y;
}
public int GetMulti(){
return X*Y;
}
public int GetDevi(){
return X/Y;
}
public int GetMod(){
return X%Y;
}
public int GetMax(){
return X>Y?X:Y;
}
public int GetMin(){
return X>Y?Y:X;
}
}
{
int x;
int y;
public int X
{
get{return x;}
set{x=value;}
}
public int Y
{
get{return y;}
set{y=value;}
}
public ClsAAA(){
x=0;
y=0;
}
public int GetSum(){
return X+Y;
}
public int GetDiff(){
return X-Y;
}
public int GetMulti(){
return X*Y;
}
public int GetDevi(){
return X/Y;
}
public int GetMod(){
return X%Y;
}
public int GetMax(){
return X>Y?X:Y;
}
public int GetMin(){
return X>Y?Y:X;
}
}
看了 定义一个类,该类具有x和y两...的网友还看了以下:
已知某有机物X的结构简式如图所示,下列有关叙述不正确的是()A.X的化学式为C10H10O6B.X 2020-05-02 …
已知f(x)是定义在[1,1]上的增函数,且f(x-2)>f(1-x),求x的取值范围.写错了,定 2020-06-03 …
已知函数y=f(x)的定义域为[-2,4],则f(x+1)的定义域为已知y=f(x+2)的定义域为 2020-06-25 …
涵数F(X)有关定义域1.设涵数F(X)=2X-1则F(X+1)F(F(X))2.涵数F(X)的定 2020-06-29 …
已知f(x)=x^2绝对值x-a为定义在R上的偶函数,a为实常数(1)求a的值(2)若已知g(x) 2020-07-13 …
为什么1/ln(x),exp(x)*ln(x),.的不定积分积不出(不能用初等函数表示)?简要说明 2020-07-23 …
已知函数f(x)=lnxa+x在x=1处的切线方程为2x-y+b=0.(Ⅰ)求实数a,b的值;(Ⅱ 2020-07-31 …
肺结核病是一种由结核杆菌引起的慢性传染病,当病人咳嗽、打喷嚏、大声说话时会喷出带有结核杆菌的飞沫,健 2020-11-02 …
f(x)=Asin(wx+a)(A>0,w>0)在x=1处取最大值,则()A.f(x-1)一定是奇函 2020-12-08 …
已知函数f(x)的定义域为(-2,2),函数g(x)=f(x-1)+f(3-2x).(1)求函数已知 2020-12-08 …