java机器人编程代码 机器人编程的程序
Java趣味Java网络机器人
package auto;import *;import java sql *;import java io *;import java util *;//import db *;public class test extends Thread{URL weburl;String urladdr;public test(){}public test(String urladdr URL weburl){this urladdr=urladdr;this weburl=weburl;}public test(String urladdr){try{this urladdr=urladdr;//weburl=new URL(urladdr);this start();}catch(Exception e){System out println(e toString());}}public InputStream getStream(String url){try{//urladdr=url;URL tempurl=new URL(url);return tempurl openStream();}catch(Exception e){System out println( hello );}return null;}public void run(){while(true){ try{getStream(urladdr);Thread sleep( );}catch(Exception e){}}}public String getStr(InputStream in){try{StringBuffer temp=null;BufferedReader buffer=new BufferedReader(new InputStreamReader(in));String tempstr= ;String strsum= ;while ((tempstr=buffer readLine())!=null){strsum=strsum+tempstr;}buffer close();//in close();return strsum;}catch(Exception e){System out println( shit );}return ;}public String getMTVURL(String ){ try{String temp= substring( lastIndexOf( / )+ );temp=temp substring( temp indexOf( \ ));temp= ?Id= ;+temp;temp=temp trim();return temp; }catch(Exception e){System out println(e toString());}return null;}public String getMTVname(String ){try{String temp= substring( indexOf( 作品名 )+ );temp=temp substring( temp indexOf( ));temp=temp trim();return temp;}catch(Exception e){System out println( hello );}return null;}public void insertdb(String MTVURL String MTVname){// DBoperate writer=new DBoperate();// String insert= insert into mtvList(mtvname mtvurl)values( +MTVname+ +MTVURL+ ) ;// writer exesql(insert);}public void getover(){InputStream in=getStream(urladdr);String content=getStr(in);String url=getMTVURL(content);String name=getMTVname(content);insertdb(url name);}public static void main(String[] avg){for(;;){try{test look=new test( ;);look getStream(look urladdr) close();Thread sleep( );}catch(Exception e){System out println(e toString());continue;}}}} lishixinzhi/Article/program/Java/hx/201311/26768
成都创新互联坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都网站设计、网站制作、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的卢氏网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!
跪求大神荣光 回答下面的机器人的JAVA代码
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class WalkDistance {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
for (int i = 0; i n; i++) {
String order = in.next();
System.out.println(new DecimalFormat("0.00").format(calDistance(order)));
}
in.close();
}
private static float calDistance(String order) {
char[] orderChar = order.toCharArray();
ListString orderList = new ArrayListString();
int num = 0;
for (int i = 0, len = orderChar.length; i len; i++) {
if (orderChar[i] = '0' orderChar[i] = '9') {
num++;
} else {
if (num == 0) {
orderList.add(String.valueOf(orderChar[i]));
} else {
StringBuffer sb = new StringBuffer();
for (int j = num; j 0; j--) {
sb.append(String.valueOf(orderChar[i - j]));
}
orderList.add(sb.toString());
orderList.add(String.valueOf(orderChar[i]));
num = 0;
}
}
if (i == len - 1 num != 0) {
StringBuffer sb = new StringBuffer();
for (int j = num - 1; j = 0; j--) {
sb.append(String.valueOf(orderChar[i - j]));
}
orderList.add(sb.toString());
}
}
Point curPoint = new Point(0, 0, 90);
for (int i = 0, len = orderList.size(); i len; i++) {
if ("R".equals(orderList.get(i))) {
curPoint.angle = (curPoint.angle - 90 + 360) % 360;
} else if ("L".equals(orderList.get(i))) {
curPoint.angle = (curPoint.angle + 90) % 360;
} else {
curPoint.setLocation(curPoint, orderList.get(i));
}
}
return curPoint.getDis();
}
static class Point {
private int x;
private int y;
private int angle;
private float dis;
public Point(int x, int y, int angle) {
this.x = x;
this.y = y;
this.angle = angle;
this.dis = (float) 0;
}
public void setLocation(Point point, String distance) {
if (point.angle == 0) {
point.x += Integer.valueOf(distance);
} else if (point.angle == 90) {
point.y += Integer.valueOf(distance);
} else if (point.angle == 180) {
point.x -= Integer.valueOf(distance);
} else {
point.y -= Integer.valueOf(distance);
}
}
public float getDis() {
return (float) Math.sqrt(this.x * this.x + this.y * this.y);
}
}
}
怎样用Java程序编写一个聊天机器人(自动和人聊天的程序)
是这样的错误么?
Frist.java:5: cannot resolve symbol
symbol : class Scanner
location: class Frist
Scanner input=new Scanner(System.in);
Scanner是JDK1.5开始才有的
这样的错误是因为JDK版本不够,不支持。。。
我用的就是1.4.2 所以是这样的错误
新闻名称:java机器人编程代码 机器人编程的程序
标题路径:http://azwzsj.com/article/dooojip.html