欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

java代碼機(jī)器人 java人工智能代碼

乞求大神榮光!!機(jī)器人的JAVA代碼。

public class Bot {

創(chuàng)新互聯(lián)主營(yíng)蒲縣網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,重慶APP開發(fā)公司,蒲縣h5成都小程序開發(fā)搭建,蒲縣網(wǎng)站營(yíng)銷推廣歡迎蒲縣等地區(qū)企業(yè)咨詢

private ArrayListString commands;

public Bot(){

commands = new ArrayList();

}

public ArrayListString getCommands(){

return commands;

}

public static void main(String[ ] args){

Bot bot = new Bot();

Scanner sc = new Scanner(System.in);

System.out.println("請(qǐng)輸入一個(gè)整數(shù):");

int n = sc.nextInt();

int i = 0;

String command;

sc.nextLine();

while (i n){

command = sc.nextLine();

if (!isCorrectCommand(command)){

System.out.println("每條指令只由L、R和數(shù)字組成(數(shù)字是0~100之間的整數(shù))。");

}else if (command.length() 256){

System.out.println("每條指令的長(zhǎng)度不超過256個(gè)字符。");

} else{

bot.getCommands().add(command);

i++;

}

}

i = 0;

while (i n){

System.out.printf("%.2f",bot.go(i));

i++;

}

}

public double go(int index){

int direction = 2;

double x = 0;

double y = 0;

String command = commands.get(index);

String str="0";

int i = 0;

char temp;

while (i command.length()){

temp = command.charAt(i);

if (temp = 47 temp = 57){

str += temp;

}else if (temp == 'L'){

int length = Integer.parseInt(str);

switch(direction){

case 1: x = x - length;break;

case 2: y = y + length;break;

case 3: x = x + length;break;

case 4: y = y - length;break;

}

str = "0";

direction = (direction - 1)%4;

if (direction == 0){

direction = 4;

}

}else{

int length = Integer.parseInt(str);

switch(direction){

case 1: x = x - length;break;

case 2: y = y + length;break;

case 3: x = x + length;break;

case 4: y = y - length;break;

}

str = "0";

direction = (direction + 1)%4;

}

i++;

}

int length = Integer.parseInt(str);

switch(direction){

case 1: x = x - length;break;

case 2: y = y + length;break;

case 3: x = x + length;break;

case 4: y = y - length;break;

}

return Math.sqrt(x * x + y * y);

}

public static boolean isCorrectCommand(String command){

Pattern pt = Pattern.compile("(?:L\\d{1,3}|R\\d{1,3}|\\d{1,3})+");

if (pt.matcher(command).matches()){

return true;

}

return false;

}

}

用java程序?qū)崿F(xiàn)

機(jī)器人類(源類):

public class Robot {

public void cry(){

System.out.println("機(jī)器人叫");

}

public void run(){

System.out.println("機(jī)器人跑");

}

}

狗類(目標(biāo)類):

public class Dog {

public void cry(){

System.out.println("像狗一樣叫");

}

public void run(){

System.out.println("像狗一樣跑");

}

}

適配器類(繼承源類并重寫它的方法,目標(biāo)類作為屬性):

public class Adaper extends Robot{

private Dog dog;

public Adaper(Dog dog) {

this.dog=dog;

}

@Override

public void cry() {

dog.cry();

}

@Override

public void run() {

dog.run();

}

}

測(cè)試類

public class Test {

public static void main(String[] args) {

Dog dog=new Dog();

Robot robot=new Adaper(dog);

robot.cry();

robot.run();

}

}

oicq機(jī)器人轉(zhuǎn)java

OICQ機(jī)器人轉(zhuǎn)Java:

1. 下載OICQ SDK并安裝:從OICQ官網(wǎng)上下載SDK并安裝到你的電腦上。

2. 創(chuàng)建一個(gè)新的Java工程:使用Eclipse或者其他IDE來創(chuàng)建一個(gè)新的Java工程。

3. 導(dǎo)入OICQ SDK庫文件:將SDK中的庫文件添加到你的工程中。

4. 生成OICQ機(jī)器人代碼:根據(jù)你想要實(shí)現(xiàn)的功能生成相應(yīng)的代碼。

5. 生成可執(zhí)行文件并測(cè)試機(jī)器人代碼:將生成的代碼生成可執(zhí)行文件并測(cè)試機(jī)器人代碼是否正常工作。

JAVA設(shè)計(jì)一個(gè)人工智能的機(jī)器人

java機(jī)器人游戲最經(jīng)典的是Robocode項(xiàng)目,里面有詳細(xì)的文檔以及源碼,可以自己學(xué)習(xí)修改。(不要說自己參加這個(gè)項(xiàng)目,自己不認(rèn)真學(xué)些東西,那可以面壁了)。下面是它的項(xiàng)目主頁

java腳本機(jī)器人模塊錯(cuò)誤

腳本程序就有問題。java腳本機(jī)器人模塊錯(cuò)誤的原因是腳本程序就有問題,Java是一門面向?qū)ο蟮木幊陶Z言,不僅吸收了C++語言的各種優(yōu)點(diǎn),還摒棄了C++里難以理解的多繼承、指針等概念,因此Java語言具有功能強(qiáng)大和簡(jiǎn)單易用兩個(gè)特征。

本文標(biāo)題:java代碼機(jī)器人 java人工智能代碼
當(dāng)前鏈接:http://chinadenli.net/article24/dodssce.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供軟件開發(fā)、域名注冊(cè)電子商務(wù)、外貿(mào)網(wǎng)站建設(shè)虛擬主機(jī)、自適應(yīng)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)