設(shè)置2個動態(tài)圖片在寫個方法

創(chuàng)新互聯(lián)建站是專業(yè)的松桃網(wǎng)站建設(shè)公司,松桃接單;提供成都網(wǎng)站制作、做網(wǎng)站,網(wǎng)頁設(shè)計,網(wǎng)站設(shè)計,建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進行松桃網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團隊,希望更多企業(yè)前來合作!
public void run() {
while (true) {
try {
Thread.sleep(30);
} catch (InterruptedException e) {
e.printStackTrace();
}
repaint();
}
jose 不動 ,maria forward(40) turn(-90)
這是java 中的方法傳參問題 ,在java中參數(shù)類型是引用類型,傳的是這個引用參數(shù)的引用的副本,在dosth()中,這個引用turtle指向了maria的地址,改變的都是maria值
System.out.println("Java龜兔賽跑:你要程序我來幫、百度Java作業(yè)幫:QQ群:Java\C\C++程序幫?426652572。")
感覺挺有趣的,試著寫了個~
public static void main(String[] arg) {
new wugui().run();
new tuzi().run();
}
static class wugui {
final int sudu = 4;// 烏龜?shù)乃俣仁敲棵?米
public static boolean hasEnd = false;// 是否已經(jīng)跑到終點
public void run() {
new Thread() {
public void run() {
int distance = 0;
while (distance 100) {
try {
Thread.sleep(1000);
distance += sudu;
System.out.println("小烏龜跑了" + distance + "米");
} catch (InterruptedException e) {
e.printStackTrace();
}
}
hasEnd = true;
if (tuzi.hasEnd) {
System.out.println("嗚嗚,差一點點就贏了~");
} else {
System.out.println("勝利是屬于有準備的人的,你的自大害了你!-------烏龜贏了");
}
}
}.start();
}
}
static class tuzi {
final int sudu = 5;// 兔子的速度是每秒5米
public static boolean hasEnd = false;// 是否已經(jīng)跑到終點
public void run() {
new Thread() {
@Override
public void run() {
int distance = 0;// 跑了多少米
boolean hasXiuXi = false;// 是否休息過
while (distance 100) {
try {
Thread.sleep(1000);
distance += sudu;
System.out.println("小兔子跑了" + distance + "米");
if (distance 50 !hasXiuXi) {
System.out.println("小兔子累了,決定休息一會兒~");
Thread.sleep((long) (10000 * Math.random()));
System.out.println("小兔子休息夠了,又開始跑了,決一勝負吧!");
hasXiuXi = true;
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
hasEnd = true;
if (wugui.hasEnd) {
System.out.println("嗚嗚,早知道就不休息了~");
} else {
System.out.println("哇哈哈,你個戰(zhàn)5渣也想贏我~~做夢去吧!!-------兔子贏了");
}
}
}.start();
}
}
import java.util.*;
public class Test{
public static void main(String[] args)throws Exception {
float t,g,m=0,num=0;
float tt,gg;
int q=0;
Scanner s;
System.out.println("輸入兔子跑一圈時間/秒:");
s=new Scanner(System.in);
t=s.nextFloat();
System.out.println("輸入烏龜跑一圈時間/秒:");
s=new Scanner(System.in);
g=s.nextFloat();
tt=(float)1/(t*1000);
gg=(float)1/(g*1000);
System.out.println("賽跑開始……");
while(true){
try{
Thread.sleep(10);
}catch(Exception e){}
m+=10;
if((int)((tt-gg)*m)q){
q=(int)((tt-gg)*m);
System.out.println("在第"+m/1000+"秒");
System.out.println("兔子超過烏龜"+q+"圈");
}
}
}}
網(wǎng)站欄目:JAVA代碼畫烏龜行走,用java畫一個烏龜
本文來源:http://chinadenli.net/article24/dsehsje.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App開發(fā)、服務(wù)器托管、網(wǎng)站設(shè)計、外貿(mào)建站、網(wǎng)站改版、軟件開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)