javaÖеÄÒ»¸öMyPoint·½·¨
Éè¼ÆÒ»¸öCircleÀ࣬ÆäÊôÐÔΪԵ㣨ÀàÐÍΪÀàMyPoint£©ºÍ°ë¾¶£¬²¢Îª´ËÀà±àдÒÔÏÂÈý¸ö·½·¨£º
Ò»¡¢¼ÆËãÔ²µÄÃæ»ýµÄcalArea£¨£©·½·¨£»
¶þ¡¢¼ÆËãÖܳ¤µÄcalLength£¨£©·½·¨£»
Èý¡¢boolean inCircle£¨MyPoint mp£©·½·¨£¬¹¦ÄÜÊDzâÊÔ×÷Ϊ²ÎÊýµÄij¸öµãÊÇ·ñÔÚµ±Ç°¶ÔÏóÔ²ÄÚ£¨Ô²ÄÚ£¬°üÀ¨Ô²ÉÏ·µ»Øtrue£¬ÔÚÔ²Íâ·µ»Øfalse£©¡£
³ÌÐò£º
class MyPoint{
private int x,y;
public void setX(int x){
this.x=x;
}
public int getX(){
return this.x;
}
public void setY(int y){
this.y=y;
}
public int getY(){
return this.y;
}
public String toString(){
String str="("+this.x+","+this.y+")";
return str;
}
}
class Circle {
private MyPoint myPoint=null;
private double radius=0.0;
public Circle(MyPoint myPoint,int radius){
this.myPoint=myPoint;
this.radius=radius;
}
public double calArea(){
return Math.PI*radius*radius;
}
public double calLength(){
return 2*Math.PI*radius;
}
public boolean inCircle(MyPoint mp){
double a=Math.sqrt(Math.pow(mp.getX()-myPoint.getY(),2)+Math.pow(mp.getY()-myPoint.getY(),2));
if(a>radius){
return false;
}
return true;
}
}
public class T14{
public static void main(String args[]){
MyPoint mp=new MyPoint();
mp.setX(0);
mp.setY(0);
Circle c=new Circle(mp,5);
double area=c.calArea();
double length=c.calLength();
MyPoint mp2=new MyPoint();
mp2.setX(3);
mp2.setY(3);
boolean in=c.inCircle(mp2);
System.out.println("area="+area+",length="+length+",inCircle="+in);
}
}
²âÊÔ½á¹û£º
Ïà¹ØÎĵµ£º
Ôںܶàʱºò£¬ÎÒÃÇÐèÒª×Ô¶¯Éú³ÉÓÀÔ¶²»»áÖظ´µÄID£¬Òò´ËÎÒÃÇ»áÓõ½ÒÔϵĴúÂëÀ´ÊµÏÖ£º
×¢Ò⣺ÐèÒª¼ÓÈëÁ½¸öapacheµÄ°ü,´úÂëºÍ°üÇë´Óhttp://www.blogjava.net/afei0922/articles/129589.html ÏÂÔØ
package cn.com.cinda.rtx.state;
import org.apache.commons.id.Hex;
public class RandomCode {
pub ......
½üÀ´Ñ§JSP+SSH£¬ÏÂÔØÁËMyEclipse 8.0 M1£¬ÍøÉÏÕÒµ½µÄ×¢²áÂëʵÔÚ²»¶à£¬ÕæµÄ²»¶à£¬¾ÍÄÇôһ¸ö£¬±¾ß°¡£¬Òª²»¾ÍÊÇ×¢²á»ú£¬ÎÞÒâÖп´µ½Ò»¸öºÃ¶«Î÷£¬ÓÃJavaÉú³É×¢²áÂ룬Ô×÷¶¼ÊÇËÎÒ²»ÖªµÀ£¬Èç¹û×÷ÕßÈÏΪÎÒ²»¸Ã°ÑÕâЩ´úÂëÌûÔÚÕâÀÇë¸æÖª£¬ÎÒÂíÉÏɾ³ý¡£²»¶à˵£¬ÉÏ´úÂ룺
import java.io.BufferedReader;
im ......
1.Ï̴߳´½¨µÄÁ½ÖÖ·½Ê½
1£©À©Õ¹ThreadÀಢÖØдpublic void run()·½·¨
ps£º
¶¨ÒåỊ̈߳º
class myThread extends Thread(){
public void run(){
System.out.println("Ju ......
Java¸ß¼¶££JavaÏß³ÌÔËÐÐÕ»ÐÅÏ¢µÄ»ñÈ¡
·¢²¼Ê±¼ä£º2007.11.14 05:10 À´Ô´£ºÈüµÏÍø¼¼ÊõÉçÇø ×÷Õߣºbaocl
Ò»¡¢ÎÊÌâµÄÒýÈë
ÎÒÃÇÔÚJava³ÌÐòÖÐʹÓÃÈÕÖ¾¹¦ÄÜ£¨JDK Log»òÕßLog4J£©µÄʱºò£¬»á·¢ÏÖLogϵͳ»á×Ô¶¯°ïÎÒÃÇ´òÓ¡³ö·á¸»µÄÐÅÏ¢£¬¸ñʽһ°ãÈçÏ£º
[ÔËÐÐʱ¼ä] [µ ......