mypoint.java~28~

来自「Java画版程序。......................要求变态。」· JAVA~28~ 代码 · 共 81 行

JAVA~28~
81
字号
package myshape;/** * Title: * Description: * Copyright:    Copyright (c) 2002 * Company: * @author * @version 1.0 */import java.awt.*;public class MyPoint extends  MyShapeAdapter{  private int x,y; //private MyCircle c; // private boolean attachToOthers=false;  public MyPoint() {  }  public MyPoint(int x,int y){  this.x=x;  this.y=y;  //attachToOthers=attached;  } private Color color; public static void setColor(Color c){   color=c; }  public void paint(Graphics g){    g.setColor(color);    g.fillOval(x-2,y-2,4,4);  }  public MyShape getShape(){      MyPoint p=(MyPoint)this.clone();    //  p.moveObject(x+4,y+4);      return p;  }  public int getX(){  return x;  }  public int getY(){  return y;  }  public boolean nearTo(MyPoint p){  int tempx=this.x-p.getX();  int tempy=this.y-p.getY();  if(tempx*tempx+tempy*tempy<4)   return true;   return false;  }  public String toString(){   String s="点 ";   return s;  }  public void setAttach( ){  }  public void moveObject(int x,int y){   this.x=x;   this.y=y;  }  public boolean nearTo(int x,int y){   if(this.attachToOthers)      return false;   int tempx=this.x-x;   int tempy=this.y-y;   if(tempx*tempx+tempy*tempy<8)     return true;   return false;  } public MyPoint getPoint(){   return this; }// public boolean moveFreely=true;// public boolean moveFo=true;}

⌨️ 快捷键说明

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