免费观看又色又爽又黄的小说免费_美女福利视频国产片_亚洲欧美精品_美国一级大黄大色毛片

關(guān)于java2048朝代代碼的信息

那個大神有完整的java,eclipse,2048游戲的源代碼,全部拷貝粘貼就能用的,給一個,在線等,急!!!

網(wǎng)上的java代碼在eclipse里運行方法:

成都創(chuàng)新互聯(lián)是一家專業(yè)提供欽南企業(yè)網(wǎng)站建設(shè),專注與成都網(wǎng)站設(shè)計、做網(wǎng)站H5高端網(wǎng)站建設(shè)、小程序制作等業(yè)務(wù)。10年已為欽南眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站設(shè)計公司優(yōu)惠進(jìn)行中。

1.打開eclipse,點擊項目的空白處,選擇import;

2.選擇Existing Project into Workspace,點擊next,找到的java代碼,導(dǎo)入到eclipse中;

3.導(dǎo)入成功之后,選擇項目,鼠標(biāo)右鍵,選擇run as,選擇一個運行方式,然后運行即可。

求2048朝代版的源代碼?

import javax.swing.*;

import java.awt.*;

@SuppressWarnings("serial")

public class Game_block extends JLabel {

private int value;

public Game_block() {

super("go!");

value = 0;

setFont(new Font("font", Font.PLAIN, 40));

setBackground(Color.black);

}

public int getValue() {

return value;

}

public void setValue(int value) {

this.value = value;

String Text = String.valueOf(value);

if (value != 0){

if(value == 2)

setText("夏");

}

if (value != 0){

if(value == 4)

setText("商");

}

if (value != 0){

if(value == 8)

setText("周");

}

if (value != 0){

if(value == 16)

setText("秦");

}

if (value != 0){

if(value == 32)

setText("漢");

}

if (value != 0){

if(value == 64)

setText("三國");

}

if (value != 0){

if(value == 128)

setText("南北朝");

}

if (value != 0){

if(value == 256)

setText("隋");

}

if (value != 0){

if(value == 1024)

setText("五代十國");

}

if (value != 0){

if(value == 2048)

setText("宋遼");

}

if (value != 0){

if(value == 4096)

setText("宋金");

}

if (value != 0){

if(value == 8192)

setText("元");

}

if (value != 0){

if(value == 16384)

setText("明");

}

if (value != 0){

if(value == 32768)

setText("清");

}

if (value != 0){

if(value == 65536)

setText("現(xiàn)代");

}

else

setText("2048");

setColor();

}

public void setColor() {

if (this.value == 0)

setBackground(Color.black);

else if (this.value == 2)

setBackground(new Color(238, 228, 218));

else if (this.value == 4)

setBackground(new Color(248, 232, 248));

else if (this.value == 8)

setBackground(new Color(243, 177, 116));

else if (this.value == 16)

setBackground(new Color(243, 177, 126));

else if (this.value == 32)

setBackground(new Color(248, 149, 90));

else if (this.value == 64)

setBackground(new Color(249, 94, 50));

else if (this.value == 128)

setBackground(new Color(239, 207, 108));

else if (this.value == 256)

setBackground(new Color(239, 207, 99));

else if (this.value == 512)

setBackground(new Color(239, 203, 82));

else if (this.value == 1024)

setBackground(new Color(239, 199, 57));

else if (this.value == 2048)

setBackground(new Color(239, 195, 41));

else if (this.value == 4096)

setBackground(new Color(255, 60, 57));

else if (this.value == 8192)

setBackground(new Color(258, 60, 59));

else if (this.value == 16384)

setBackground(new Color(262, 62, 59));

else if (this.value == 32768)

setBackground(new Color(262, 64, 62));

else if (this.value == 65536)

setBackground(new Color(264, 64, 66));

}

}

______________________________________________________

import java.awt.*;

import java.awt.event.KeyEvent;

import java.awt.event.KeyListener;

import java.awt.event.MouseAdapter;

import java.awt.event.MouseEvent;

import javax.swing.*;

@SuppressWarnings("serial")

public class Game_my2048 extends JFrame implements KeyListener {

Game_block[] block;

JPanel panel;

boolean numFlag;

int moveFlag;

int a ;//a 的引入是為了防止連加的情況出現(xiàn)

public Game_my2048() {

numFlag = true;

moveFlag = 0;

block = new Game_block[16];

setTitle("2048朝代版");

setSize(400, 400);

setLocation(500, 200);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

panel = (JPanel) getContentPane();

panel.setLayout(new GridLayout(4, 4, 5, 5));

addBlock();

for (int i = 0; i 2; i++)

appearBlock();

this.addKeyListener(this);

this.setVisible(true);

}

public void addBlock() {

for (int i = 0; i 16; i++) {

block[i] = new Game_block();

block[i].setHorizontalAlignment(JLabel.CENTER);

// 不透明

block[i].setOpaque(true);

panel.add(block[i]);

}

}

public void appearBlock() {

while(numFlag) {

int index = (int) (Math.random() * 16);

if (block[index].getValue() == 0) {

if (Math.random() 0.5)

block[index].setValue(2);

else

block[index].setValue(4);

break;

}

}

}

public void judgeAppear() {

int sum = 0;

for (int i = 0; i 16; i++) {

if (block[i].getValue() != 0)

sum++;

}

if (sum == 16)

numFlag = false;

}

public void upBlock() {

for (int i = 12; i 16; i++) {

int index = i;

for (int j = i - 4; j = i - 12; j -= 4) {

int valueI = block[index].getValue(), valueJ = block[j]

.getValue();

if (valueJ == 0) {

block[index].setValue(0);

block[j].setValue(valueI);

} else {

if (valueI == valueJ) {

block[index].setValue(0);

block[j].setValue(valueI + valueJ);

if (valueI + valueJ == 4096)

win();

numFlag = true;

moveFlag = 0;

} else if (numFlag == false)

moveFlag += 1;

}

index = j;

}

}

}

public void downBlock() {

for (int i = 0; i 4; i++) {

a = 5;

int index = i;

for (int j = i + 4; j = i + 12; j += 4) {

int valueI = block[index].getValue(), valueJ = block[j]

.getValue();

if (valueJ == 0) {

block[index].setValue(0);

block[j].setValue(valueI);

} else {

if (valueI == valueJ) {

block[index].setValue(0);

block[j].setValue(valueI + valueJ);

if (valueI + valueJ == 4096)

win();

numFlag = true;

moveFlag = 0;

} else if (numFlag == false)

moveFlag += 1;

}

index = j;

}

}

}

public void rightBlock() {

for (int i = 0; i = 12; i += 4) {

int index = i;

for (int j = i + 1; j = i + 3; j++) {

int valueI = block[index].getValue(), valueJ = block[j]

.getValue();

if (valueJ == 0) {

block[index].setValue(0);

block[j].setValue(valueI);

} else {

if (valueI == valueJ) {

block[index].setValue(0);

block[j].setValue(valueI + valueJ);

if (valueI + valueJ == 4096)

win();

numFlag = true;

moveFlag = 0;

} else if (numFlag == false)

moveFlag += 1;

}

index = j;

}

}

}

public void leftBlock() {

for (int i = 3; i = 15; i += 4) {

int index = i;

for (int j = i - 1; j = i - 3; j--) {

int valueI = block[index].getValue(), valueJ = block[j]

.getValue();

if (valueJ == 0) {

block[index].setValue(0);

block[j].setValue(valueI);

} else {

if (valueI == valueJ) {

block[index].setValue(0);

block[j].setValue(valueI + valueJ);

if (valueI + valueJ == 4096)

win();

numFlag = true;

moveFlag = 0;

} else if (numFlag == false)

moveFlag += 1;

}

index = j;

}

}

}

@Override

public void keyPressed(KeyEvent e) {

switch (e.getKeyCode()) {

case KeyEvent.VK_UP:

upBlock();

judgeAppear();

appearBlock();

over();

break;

case KeyEvent.VK_DOWN:

downBlock();

judgeAppear();

appearBlock();

over();

break;

case KeyEvent.VK_LEFT:

leftBlock();

judgeAppear();

appearBlock();

over();

break;

case KeyEvent.VK_RIGHT:

rightBlock();

judgeAppear();

appearBlock();

over();

break;

}

}

public void over() {

if (!numFlag moveFlag = 36) {

block[4].setText("G");

block[5].setText("A");

block[6].setText("M");

block[7].setText("E");

block[8].setText("O");

block[9].setText("V");

block[10].setText("E");

block[11].setText("R");

block[11].addMouseListener(new MouseAdapter() {

@Override

public void mousePressed(MouseEvent e) {

reStart();

}

});

}

}

public void win() {

block[0].setText("Y");

block[1].setText("O");

block[2].setText("U");

block[13].setText("W");

block[14].setText("I");

block[15].setText("N");

block[15].addMouseListener(new MouseAdapter() {

@Override

public void mousePressed(MouseEvent e) {

reStart();

}

});

}

public void reStart(){

numFlag=true;

moveFlag=0;

for(int i=0;i 16;i++)

block[i].setValue(0);

for (int i = 0; i 2; i++)

appearBlock();

}

@Override

public void keyTyped(KeyEvent e) {

}

@Override

public void keyReleased(KeyEvent e) {

}

public static void main(String args[]) {

JFrame.setDefaultLookAndFeelDecorated(true);

new Game_my2048();

}

}

__________________________________________________________________________

這個代碼卻少很多功能的

菜鳥學(xué)習(xí)java,求大神解釋下面的代碼各段是什么意思,盡量詳細(xì),謝謝

Zip.java

import java.io.*;

import java.util.zip.*;

public class Zip {

static final int BUFFER = 2048; // 定義緩沖區(qū)大小

public static void main (Stringargv[]) {

try {

BufferedInputStream origin= null; // 創(chuàng)建帶有緩沖區(qū)的inputstrream

FileOutputStream dest = new

FileOutputStream("c:\\zip\\myfigs.zip"); // 創(chuàng)建文件輸出流,并打開zip文件 CheckedOutputStream checksum = new

CheckedOutputStream(dest,new Adler32()); // 創(chuàng)建過濾流,并驗證數(shù)據(jù)的完整性

ZipOutputStream out = new

ZipOutputStream(new

BufferedOutputStream(checksum)); // 創(chuàng)建壓縮文件輸出流,并傳入?yún)?shù)

//out.setMethod(ZipOutputStream.DEFLATED);

byte data[] = newbyte[BUFFER]; // 創(chuàng)建字節(jié)數(shù)組

// get a list of files fromcurrent directory

File f = newFile("."); // 創(chuàng)建File變量讀取根目錄用于文件的讀寫

String files[] = f.list(); // 讀取f文件夾下所有的文件名

for (int i=0; i files.length; i++) { // 根據(jù)文件名的數(shù)量進(jìn)行循環(huán)

System.out.println("Adding: "+files[i]); // 打印出添加的文件名到控制臺

FileInputStream fi = new

FileInputStream(files[i]); // 創(chuàng)建文件讀取流,讀取當(dāng)前循環(huán)到的文件

origin = new

BufferedInputStream(fi, BUFFER); // 把文件流放入帶有緩沖區(qū)的inputstream,并指定緩沖區(qū)大小

ZipEntry entry = newZipEntry(files[i]); // 創(chuàng)建zip壓縮入口實例化,放入當(dāng)前循環(huán)到的文件

out.putNextEntry(entry); // 輸出流中放入壓縮的文件

int count;

while((count =origin.read(data, 0,

BUFFER)) != -1) {// 當(dāng)count值等于緩沖區(qū)讀取的數(shù)據(jù)字節(jié)大小,且不等于-1

out.write(data, 0,count); // 輸出流寫入count字節(jié)大小的數(shù)據(jù)

}

origin.close();// 關(guān)閉帶有緩沖區(qū)的inputstream

}

out.close(); // 關(guān)閉輸出流

System.out.println("checksum:

"+checksum.getChecksum().getValue()); // 打印驗證壓縮文件的值到控制臺

} catch(Exception e) { // 捕捉異常

e.printStackTrace(); // 打印異常信息

}

}

}

2048朝代版怎么玩

2048朝代版玩法和2048數(shù)字版一樣,可以選擇上下左右其中一個方向去滑動,不同的是將數(shù)字變成了中國自夏開始的各個朝代,就是兩個夏拼成一個商,兩個商拼成一個周...每次碰撞后便生成下一個朝代,以此類推直到中華人民共和國完成通關(guān)。

一邊用數(shù)學(xué)邏輯玩游戲,一邊又在溫習(xí)華夏5000年歷史,讓不少人覺得這一改版對于中國人來說甚至超過了原版游戲,不過對于小編這種歷史缺乏的人群來說,2048朝代版太難,不如2048數(shù)字版簡單易懂。歷史缺乏的小伙伴當(dāng)然也可通過屏幕方塊的顏色來判斷。

當(dāng)前標(biāo)題:關(guān)于java2048朝代代碼的信息
路徑分享:http://m.newbst.com/article18/hihggp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化網(wǎng)站設(shè)計公司靜態(tài)網(wǎng)站服務(wù)器托管面包屑導(dǎo)航網(wǎng)站營銷

廣告

聲明:本網(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)

h5響應(yīng)式網(wǎng)站建設(shè)