javaÖеÄ̰ʳÉßÀý³Ì
×î½üÒªÖØÐÂѧϰJava£¬ÕÒ¸öÀý×ÓÀ´Êµ¼ù£¬ÔÚÍøÉÏÕÒÁ˺ܶàÀý³ÌÀ´¿´£¬×Ô¼ºÖØбàдÁËÒ»¸ö̰ʳÉßµÄÀý×Ó£¬¼ÇÔÚÕâÀï¡£
1.SnakeModel.java
import java.util.Observable;
import java.util.LinkedList;
import java.util.Arrays;
import java.util.Random;
import javax.swing.*;
//ObservableÀàÒ»°ã´ú±íÊý¾Ý£¬ÊµÏÖ½Ó¿ÚRunnable±íÃ÷´´½¨Ò»¸ö½ø³Ì
public class SnakeModel extends Observable implements Runnable {
boolean[][] matrix; //ָʾλÖÃÉÏÊÇ·ñÓÐÉßÌå»òʳÎ
LinkedList nodeArray = new LinkedList(); //ÉßÌå
Node food;
int maxX; //XÖá±ßÏߣ¬¼´Îª»²¼ÖÐXÖá¸öÊý
int maxY; //yÖá±ßÏߣ¬¼´Îª»²¼ÖÐYÖá¸öÊý
int direction = UP; //ÉßÔËÐеķ½Ïò,³õʼΪÏòÉÏ£¨UP£©
boolean isRunning = false; //ÔËÐÐ״̬
int timeInterval = 200; //ʱ¼ä¼ä¸ô£¬ºÁÃ뼶
double speedChangeRate = 0.75; //ÿ´ÎµÄËٶȱ仯ÂÊ
boolean isPaused = false ;//ÔÝÍ£±êÖ¾
int score = 0; //µÃ·Ö
int countMove = 0; //³Ôµ½Ê³ÎïÇ°Òƶ¯µÄ´ÎÊý
public static final int UP = 2;
public static final int DOWN =4;
public static final int LEFT= 1;
public static final int RIGHT =3;
public SnakeModel(int maxX, int maxY){
this.maxX = maxX;
this.maxY = maxY;
reset();
}
public void reset(){
direction = SnakeModel.UP;
timeInterval = 200;
isPaused = false;
score = 0;
countMove = 0;
//³õʼ»¯¾ØÕó
matrix = new boolean[maxX][];
for(int i = 0; i < maxX; ++i){
//¹ØÓÚÊý×éµÄн¨
matrix[i] = new boolean[maxY];
Arrays.fill(matrix[i],false);
}
//³õʼ»¯ÉßÌå
//³õʼÉßÌ峤¶È°´ÕÕºáÖáµÄ³¤¶È£¬ÈôºáÖá>20,ÔòÉßÌ峤¶ÈΪ10£¬·ñÔòΪºáÖáÒ»°ë
int initArrayLength = maxX > 20 ? 10 : maxX / 2;
nodeArray.clear();
for(int i = 0; i < initArrayLength; ++i){
int x = maxX / 2;
int y = maxY / 2;
nodeArray.addLast(new Node(x, y));
matrix[x][y] = true;
}
//´´½¨Ê³Îï
food = createFood();
matrix[food.x][food.y] = true;
}
public void changeDirection(int newDirection){
//¸Ä±ä·½Ïò²»ÄÜÓëÔ·½ÏòͬÏò»ò·´Ïò
if((direction & 1
Ïà¹ØÎĵµ£º
ÓÐÁ½ÖÖ·½·¨£º
·½·¨Ò»£ºÓÃjava.util.DateÀàÀ´ÊµÏÖ£¬²¢½áºÏjava.text.DateFormatÀàÀ´ÊµÏÖʱ¼äµÄ¸ñʽ»¯£¬¿´ÏÂÃæ´úÂ룺
import java.util.*;
import java.text.*;
//ÒÔÏÂĬÈÏʱ¼äÈÕÆÚÏÔʾ·½Ê½¶¼ÊǺºÓïÓïÑÔ·½Ê½
//Ò»°ãÓïÑÔ¾ÍĬÈϺºÓï¾Í¿ÉÒÔÁË£¬Ê±¼äÈÕÆڵĸñʽĬÈÏΪMEDIUM·ç¸ñ£¬±ÈÈ磺2008-6-16 20:54:53
//ÒÔÏÂÏÔʾµÄÈ ......
´úÂëÈçÏ£º
¡¡¡¡ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º
¡¡¡¡package com.example.pinyin.demo2;
¡¡¡¡import net.sourceforge.pinyin4j.PinyinHelper;
¡¡¡¡import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
¡¡¡¡import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
¡¡¡¡import net.sourceforge.pinyin4j.form ......
package fileIo;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
public&nb ......
ÏÂÃæÕâƪÎÄÕÂÊÇ̨ÍåÖøÃûJavaÂÛ̳“Javaworld”µÄÒ»¸ö×ÊÉî°æÖ÷дµÄÒ»·â¶ÔJavaÐÂÊÖµÄÐÅ£¬Ï£ÍûС×é³ÉÔ±×Ðϸ¿´Ï Äã»áѧµ½ºÜ¶àµÄ¡¢¡¢¡¢¡¢
親愛µÄ java ÐÂÊÖ們 :
ºÜ¸ß興Äã們願Òâ來這裡¹²Í¬學習,
Java 這個語ÑÔ, ÒÑ ......
µ½SunÍøÕ¾ÏÂÔØ×Ô½âѹ°²×°°üjdk-xxxx.bin
°²×°£º
[root@RHEL4 JDK-1.5.0.06]# chmod +x jdk-xxxx.bin
[root@RHEL4 JDK-1.5.0.06]# ./jdk-xxxx.bin
Ñ¡Ôñ°²×°Î»Öã¬
J2SDK°²×°Ä¿Â¼£º /usr/local/jdk
ÅäÖÃJava»·¾³±äÁ¿£º
ÔÚ ~/.bash_profile Àï¼ÓÈëÏÂÁм¸Ðл·¾³±äÁ¿¼´¿É£º
export JAVA_HOME=/usr/local/jdk
export PAT ......