题目详情
当前位置:首页 > 计算机考试 > 中级软件设计师
题目详情:
发布时间:2023-11-10 21:42:07

[简答题][说明]
以下程序实现了利用鼠标任意移动圆形的位置,仔细阅读代码和相关注释,将程序补充完整。
[代码6-1]
import java.awt.*;
import java.awt.event.*;
public class CIUSAMPLE extends Frame implements MouseMotionListener, MouseListener

static CIUSAMPLE frm=new CIUSAMPLE ( );
int x=70,y=60,posX=70,posY=60,dx,dy;
public static void main (String args[])

frm.setTitle ("Dragging a circle");
frm.setSize (200,150);
(1)
ffm.addMouseMotionListener (frm);
frm.setVisible (true);

public void mousePressed (MouseEvent e)

(2)
dy=e.getY ( ) -posY;

public void mouseDragged (MouseEvent e)

(3)
y=e.getY ( ) -dy;
if(dx>0&&dx<50&&dy>0&&dy<50) //如果指针落在正方形区域内

Graphicsg=getGraphics ( );
(4)


public void paint (Graphics g)

g.setColor (Color.pink); //设置绘图颜色为粉红
g.fillOval(x,y,50

更多"[说明] 以下程序实现了利用鼠标任意移动圆形的位置,仔细阅读代码和相"的相关试题:

[简答题][说明]
以下程序实现了利用鼠标任意移动圆形的位置,仔细阅读代码和相关注释,将程序补充完整。
[代码6-1]
import java.awt.*;
import java.awt.event.*;
public class CIUSAMPLE extends Frame implements MouseMotionListener, MouseListener

static CIUSAMPLE frm=new CIUSAMPLE ( );
int x=70,y=60,posX=70,posY=60,dx,dy;
public static void main (String args[])

frm.setTitle ("Dragging a circle");
frm.setSize (200,150);
(1)
ffm.addMouseMotionListener (frm);
frm.setVisible (true);

public void mousePressed (MouseEvent e)

(2)
dy=e.getY ( ) -posY;

public void mouseDragged (MouseEvent e)

(3)
y=e.getY ( ) -dy;
if(dx>0&&dx<50&&dy>0&&dy<50) //如果指针落在正方形区域内

Graphicsg=getGraphics ( );
(4)


public void paint (Graphics g)

g.setColor (Color.pink); //设置绘图颜色为粉红
g.fillOval(x,y,50
[填空题]【说明】 以下程序实现了利用鼠标任意移动该圆形的位置,仔细阅读代码和相关注释,将程序补充完整。 【代码6】 import java.awt.*; import java.awt.event.*; public class CIUSAMPLE extends Frame implements MouseMotionListener, MouseListener { static CIUSAMPLE frm=new CIUSAMPLE ( ); int x=70,y=60,posX=70,posY=60,dx,dy; public static void main ( String args[]) { frm.setTitle ("Dragging a circle"); frm.setSize ( 200,150 ); (1) frm.addMouseMotionListener ( frm ); frm. setVisible ( true ); } public void mousePressed ( MouseEvent e ) { (2) dy=e.getY ( ) -posY; } public void mouseDragged ( MouseEvent e ) { (3) y=e.getY ( ) -dy; if ( dx>0 && dx<50 && dy>0 && dy<50 ) //如果指我落在正方形区域内 { Graphics g=getGraphics ( ); (4) } } public void paint ( Graphics g ) { g.setColor ( Color. pink ); // 设置绘图颜色为粉红 g.fillOval ( x,y,50,50 ); //以基准点为图形的左上角绘出圆形 (5) pos
[简答题][说明] 以下程序实现了在applet里移动图形文件,仔细阅读代码和相关注释,将程序补充完整。 [代码6-1] import j ava. awt. *; import j ava.awt.event.*; import java.applet. Applet; public class AppCIU extends Applet implements MouseMotionListener, MouseListener { Image IMG onClick=over(this) title=放大; // 声明 Image 类类型的变量 IMG onClick=over(this) title=放大 int x=70,y=60,posX=70,posY=60,dx,dy; public void init ( ) { IMG onClick=over(this) title=放大=getImage ( getCodeBase ( ) ,"mouse.gif" ); //载入影像 addMouseListener ( this ); addMouseMotionListener ( this );   } public void mousePressed ( MouseEvent e ) { dx=e.getX( )-posX; //取得按下之点与基准点X方向的距离 dy=e.getY( )-posY; //取得按下之点与基准点Y方向的距离 } public void mouseDragged ( MouseEvent e ) { (1) (2) if ( dx>0 && dx<120 && dy>0 && dy<60 ) //如果指针落在图形上方 { Graphics g=getGraphics ( ); (3) } } public void paint ( Graphics g ) { (4) (5
[多项选择][说明]
以下程序实现了在applet里移动图形文件,仔细阅读代码和相关注释,将程序补充完整。
[代码6-1]
import j ava. awt. *;
import j ava.awt.event.*;
import java.applet. Applet;
public class AppCIU extends Applet implements MouseMotionListener, MouseListener

Image img; // 声明 Image 类类型的变量 img
int x=70,y=60,posX=70,posY=60,dx,dy;
public void init ( )

img=getImage ( getCodeBase ( ) ,"mouse.gif" ); //载入影像
addMouseListener ( this );
addMouseMotionListener ( this );
 
public void mousePressed ( MouseEvent e )

dx=e.getX( )-posX; //取得按下之点与基准点X方向的距离
dy=e.getY( )-posY; //取得按下之点与基准点Y方向的距离

public void mouseDragged ( MouseEvent e )

(1)
(2)
if ( dx>0 && dx<120 && dy>0 && dy<60 ) //如果指针落在图形上方

Graphics g=getGraphics ( );
(3)


public void paint ( Graphics g )

(4)

[简答题][说明] 以下JAVA程序实现了在接口interface iShape2D的定义和应用,仔细阅读代码和相关注释,将程序补充完整。 [代码6-1] interface iShape2D //定义接口 { (1) (2) } (3) //实现CRectangle类 { int width, height; (4) CRectangle (int w,int h) { width=w; height=h; } public void area ( ){ //定义area( )的处理方式 System. out.println ("area="+width*height); } } (5) //实现CCircle类 { double radius; (6) CCircle (double r) { radius=r; } public void area ( ) { //定义area( )的处理方式 System.out.println ("area="+pi*radius*radius); } } [代码6-2] public class app10_4 { public static void main(String args[]) { CRectangle rect=new CRectangle (5,10); rect.area ( ); //调用CRectangle类里的area ( ) method CCircle cir=new CCircle (2.0); cir.area ( ); //调用CCircl类里的area ( ) method } }
[简答题][说明]
以下JAVA程序实现了在接口interface iShape2D的定义和应用,仔细阅读代码和相关注释,将程序补充完整。
[代码6-1]
interface iShape2D //定义接口

(1)
(2)

(3) //实现CRectangle类

int width, height;
(4) CRectangle (int w,int h)
width=w;
height=h;

public void area ( ) //定义area( )的处理方式
System. out.println ("area="+width*height);


(5) //实现CCircle类

double radius;
(6) CCircle (double r)
radius=r;

public void area ( ) //定义area( )的处理方式
System.out.println ("area="+pi*radius*radius);


[代码6-2]
public class app10_4

public static void main(String args[])

CRectangle rect=new CRectangle (5,10);
rect.area ( ); //调用CRectangle类里的area ( ) method
CCircle cir=new CCircle (2.0);
cir.area ( ); //调用CCircl类里的area ( ) method


[简答题][说明] 以下代码实现了对象引用作为函数参数,仔细阅读以下代码,分析运行结果,填入 (n) 处。 [代码] #include<iostream.h> class Sample { int x,y; public: Sample( ) {x=y=0; } Sample (int i, int j ) {x=i; y=j; } void copy ( Sample &s )., void setxy ( int i, int j ) {x=i; y=j; } void print ( {cout<<"x="<<x<<end1 ; cout <<"y="<<y<<end1; }; void Sample: copy ( Sample &s ) { X=S.X; y=s.y; } void func ( Sample s1, Sample &s2 ) { s1.setxy ( 10,20 ); s2.setxy ( 30,40 ); } void main ( ) { Sample p ( 1,2 ) ,q; q.copy ( p ); time ( p,q ); p.print ( ); q.print ( ); } 运行结果 (1) (2) (3) (4)
[简答题][说明]
以下代码实现了对象引用作为函数参数,仔细阅读以下代码,分析运行结果,填入 (n) 处。
[代码]
#include<iostream.h>
class Sample

int x,y;
public:
Sample( ) x=y=0;
Sample (int i, int j ) x=i; y=j;
void copy ( Sample &s ).,
void setxy ( int i, int j ) x=i; y=j;
void print ( cout<<"x="<<x<<end1 ; cout <<"y="<<y<<end1;
;
void Sample: copy ( Sample &s )

X=S.X;
y=s.y;

void func ( Sample s1, Sample &s2 )

s1.setxy ( 10,20 );
s2.setxy ( 30,40 );

void main ( )

Sample p ( 1,2 ) ,q;
q.copy ( p );
time ( p,q );
p.print ( );
q.print ( );

运行结果
(1)
(2)
(3)
(4)
[填空题]以下所列程序的功能是:在窗体上有一个文本框控件,程序运行后,用户可以利用鼠标左键来拖动该文本框控件(注意:拖动时,文本框移动的距离和方向由鼠标指针移动的距离和方向来确定),按下鼠标右键则可以在文本框中显示出当前文本控件的位置。 Public yx As Integer Public yy As Integer Private Sub Form_ MouseMove(Button AS Integer,Shift As Integer,_ X As Single,Y As Single) If Button=1 Then Text1.Left= 【11】 Text1.Top= 【12】 End If End Sub Private Sub Form_ MouseDown (Button As Integer,Shift As Integer,_ X As Single,Y As Single) If 【13】 Then yx=Text1.Left-X yy=Text1.Top-Y End If If Button=2 Then Text1.Text=“X坐标:”+Str(Text1.Left)+“Y坐标:”+Str(Text1.Top) End If End Sub
[简答题]
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。
【说明】以下程序实现了二叉树的结点删除算法,若树中存在要删除的结点,则删除它,否则返回。 FindNode ( )函数能够在二叉树中找到给定值的结点,并返回其地址和父结点。
【C++程序】
template < class T >
void BinSTree < T >: :Delete( const T& item)
{
TreeNode < T > * DelNodePtr, * ParNodePtr, * RepNodePtr;
if(( DelNodePtr = FindNode (item,ParNodePtr)) = = NULL)
(1)
if(DelNodePtr→right = = NULL) //被删除结点只有一个子结点的情况
RepNodePtr = DelNodePtr→left;
else if( DelNodePtr→left = = NULL)
(2) ;
else // 被删除结点有两个子结点的情况
{
TreeNode < T >* PofRNodePtr = DelNodePtr;
RepNodePtr = DelNodePtr→left;
while(RepNodePtr→right ! = NULL)
{ //定位左子树的最右结点
PofRNodePtr =RepNodePtr;
RepNodePtr = RepNodePtr→right;
}
if(PofRNodePtr = = DelNodePtr) //左子树没有右子结点
(3) ;
else //用左子顷的最右结点替换删除的结点
{
(4)

[多项选择]【说明】
以下程序实现数据的排序,将n个整数分别按照升序和降序进行排序,类SortInt_1实现升序排序,类SortInt_2实现降序排序。
【Java代码】
class SortInt_1
int i,i,k,temp;
void SortInt(int a1,int a2[])//升序排序
for(i=0;i<a1-1;i++)
k=i;
for(j=i+1;j<a1;j++)
if( (1) ) k=j;
if(k !=i)
temp=a2[i];a2[i]=a2[k];a2[k]=temp;





class SortInt_2 (2)
int i,j,k,temp;
void SortInt(int a1, int a2[])//降序排序
for(i=0; i<a1-1;i++)
k=i;
for(j=i+1;j<a1;j++)
if( (3) )k=j;

if(k !=i)
temp=a2[i];a2[i]=a2[k];a2[k]=temp;




public class test
public static void main(String args[])
int a[]=10,55,100,35,87,90,100,16;
SortInt_1 NewInt= (4) ;
NewInt.SortInt(a.lenvh,a);//调用SortInt_1类的方法
System.out.prin
[简答题]仔细阅读以下3个案例,试分析案例中是否涉及到缴纳土地增值税,并说明理由。(不用计算出应纳税额) (1) 某村将集体所有的100亩果园转让给某房地产公司,用于建造高级公寓,取得收入1800万元。 (2) 某市国土资源局将国有的50亩土地出让给某房地产公司,用于建造度假村,取得土地出让金600万元。 (3) 某事业单位与某房地产企业签订协议合作建商品房,事业单位提供一块80亩的土地,房地产公司提供1000万元的资金,房屋建成后,双方按照5:5的比例分配,事业单位将分得的房产销售给自己的职工。
[简答题][说明] 下面代码实现类A、B、C、D的继承定义和应用。仔细阅读[代码5-1],在 (n) 处写出正确的运行结果。 [代码5-1] #include<iostream.h> class A { public: int a; A (int v1): a(v1) {} //构造函数 void disp ( ) { cout<<"a in class A="<<a<<endl; } }; class B: virtual public A { public: int b; B (int v1,int v2): A(v1),b v2) {} //构造函数 void disp ( ) { cout<<"a in class B="<<a<<endl cout<<"b in class B="<<b<<endl; } }; class C: virtual public A { public: int c; C (int v1,int v2): A(v1) ,c(v2) {} //构造函数 void disp ( ) { cout<<"a in class C="<<a<<endl; cout<<"c in class C="<<c<<endl; } }; class D: public B, public C { public: int d; D (int v1,int v2,int v3,int v4 ): A(v1) ,B(v1,v2) ,C(v1,v3),d(v4) {} //构造函数 void disp ( ) { cout<<"a="<<a<<endl; cout<<"b="<< b<<endl; cout<<"c="<<c<<endl; cout<<"d="<<d<<endl; } }; void main( ) { D demo (10,20,30,40); demo.disp ( ); } [运行
[填空题]以下程序实现的功能是 【4】 ,结果存放在AX中。
START: IN AL,20H
MOV BL,AL
IN AL,30H
MOV CL,AL
MOV AX,0
NEXT: ADD AL,BL
ADC AH,0
DEC CL
JNZ NEXT
HLT

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
  • 支付完成
  • 取消支付
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码