真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

java帥氣代碼 java酷炫代碼

Java編程,填寫下面的代碼

class NoLowerLetterException extends Exception {

讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對(duì)這個(gè)行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長期合作伙伴,公司提供的服務(wù)項(xiàng)目有:域名與空間、雅安服務(wù)器托管、營銷軟件、網(wǎng)站建設(shè)、寬甸網(wǎng)站維護(hù)、網(wǎng)站推廣。

public NoLowerLetterException(String msg) {

super(msg);

}

}

class NoDigitException extends Exception {

public NoDigitException(String msg) {

super(msg);

}

}

class People {

void printLetter(char c) {

if (c = 'a' c = 'z') {

System.out.println(c);

} else {

try {

throw new NoLowerLetterException(String.valueOf(c));

} catch (NoLowerLetterException e) {

e.printStackTrace();

}

}

}

void printDigit(char c) {

if (c = '0' c = '9') {

System.out.println(c);

} else {

try {

throw new NoDigitException(String.valueOf(c));

} catch (NoDigitException e) {

e.printStackTrace();

}

}

}

}

public class ExceptionExample {

public static void main(String args[]) {

People people = new People();

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

// 【代碼5】

// //將i轉(zhuǎn)換為char類型,執(zhí)行people.printLetter()方法,如果出現(xiàn)異常則捕獲,并輸出異常的錯(cuò)誤信息!

people.printLetter((char) i);

}

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

// 【代碼6】 //將i轉(zhuǎn)換為char類型,執(zhí)行people. printDigit

// ()方法,如果出現(xiàn)異常則捕獲,并輸出異常的錯(cuò)誤信息!

people.printDigit((char) i);

}

}

}

求java小游戲源代碼

表1. CheckerDrag.java

// CheckerDrag.javaimport java.awt.*;import java.awt.event.*;public class CheckerDrag extends java.applet.Applet{ // Dimension of checkerboard square. // 棋盤上每個(gè)小方格的尺寸 final static int SQUAREDIM = 40; // Dimension of checkerboard -- includes black outline. // 棋盤的尺寸 – 包括黑色的輪廓線 final static int BOARDDIM = 8 * SQUAREDIM + 2; // Dimension of checker -- 3/4 the dimension of a square. // 棋子的尺寸 – 方格尺寸的3/4 final static int CHECKERDIM = 3 * SQUAREDIM / 4; // Square colors are dark green or white. // 方格的顏色為深綠色或者白色 final static Color darkGreen = new Color (0, 128, 0); // Dragging flag -- set to true when user presses mouse button over checker // and cleared to false when user releases mouse button. // 拖動(dòng)標(biāo)記 --當(dāng)用戶在棋子上按下鼠標(biāo)按鍵時(shí)設(shè)為true, // 釋放鼠標(biāo)按鍵時(shí)設(shè)為false boolean inDrag = false; // Left coordinate of checkerboard's upper-left corner. // 棋盤左上角的左方向坐標(biāo) int boardx; // Top coordinate of checkerboard's upper-left corner. //棋盤左上角的上方向坐標(biāo) int boardy; // Left coordinate of checker rectangle origin (upper-left corner). // 棋子矩形原點(diǎn)(左上角)的左方向坐標(biāo) int ox; // Top coordinate of checker rectangle origin (upper-left corner). // 棋子矩形原點(diǎn)(左上角)的上方向坐標(biāo) int oy; // Left displacement between mouse coordinates at time of press and checker // rectangle origin. // 在按鍵時(shí)的鼠標(biāo)坐標(biāo)與棋子矩形原點(diǎn)之間的左方向位移 int relx; // Top displacement between mouse coordinates at time of press and checker // rectangle origin. // 在按鍵時(shí)的鼠標(biāo)坐標(biāo)與棋子矩形原點(diǎn)之間的上方向位移 int rely; // Width of applet drawing area. // applet繪圖區(qū)域的寬度 int width; // Height of applet drawing area. // applet繪圖區(qū)域的高度 int height; // Image buffer. // 圖像緩沖 Image imBuffer; // Graphics context associated with image buffer. // 圖像緩沖相關(guān)聯(lián)的圖形背景 Graphics imG; public void init () { // Obtain the size of the applet's drawing area. // 獲取applet繪圖區(qū)域的尺寸 width = getSize ().width; height = getSize ().height; // Create image buffer. // 創(chuàng)建圖像緩沖 imBuffer = createImage (width, height); // Retrieve graphics context associated with image buffer. // 取出圖像緩沖相關(guān)聯(lián)的圖形背景 imG = imBuffer.getGraphics (); // Initialize checkerboard's origin, so that board is centered. // 初始化棋盤的原點(diǎn),使棋盤在屏幕上居中 boardx = (width - BOARDDIM) / 2 + 1; boardy = (height - BOARDDIM) / 2 + 1; // Initialize checker's rectangle's starting origin so that checker is // centered in the square located in the top row and second column from // the left. // 初始化棋子矩形的起始原點(diǎn),使得棋子在第一行左數(shù)第二列的方格里居中 ox = boardx + SQUAREDIM + (SQUAREDIM - CHECKERDIM) / 2 + 1; oy = boardy + (SQUAREDIM - CHECKERDIM) / 2 + 1; // Attach a mouse listener to the applet. That listener listens for // mouse-button press and mouse-button release events. // 向applet添加一個(gè)用來監(jiān)聽鼠標(biāo)按鍵的按下和釋放事件的鼠標(biāo)監(jiān)聽器 addMouseListener (new MouseAdapter () { public void mousePressed (MouseEvent e) { // Obtain mouse coordinates at time of press. // 獲取按鍵時(shí)的鼠標(biāo)坐標(biāo) int x = e.getX (); int y = e.getY (); // If mouse is over draggable checker at time // of press (i.e., contains (x, y) returns // true), save distance between current mouse // coordinates and draggable checker origin // (which will always be positive) and set drag // flag to true (to indicate drag in progress). // 在按鍵時(shí)如果鼠標(biāo)位于可拖動(dòng)的棋子上方 // (也就是contains (x, y)返回true),則保存當(dāng)前 // 鼠標(biāo)坐標(biāo)與棋子的原點(diǎn)之間的距離(始終為正值)并且 // 將拖動(dòng)標(biāo)志設(shè)為true(用來表明正處在拖動(dòng)過程中) if (contains (x, y)) { relx = x - ox; rely = y - oy; inDrag = true; } } boolean contains (int x, int y) { // Calculate center of draggable checker. // 計(jì)算棋子的中心位置 int cox = ox + CHECKERDIM / 2; int coy = oy + CHECKERDIM / 2; // Return true if (x, y) locates with bounds // of draggable checker. CHECKERDIM / 2 is the // radius. // 如果(x, y)仍處于棋子范圍內(nèi)則返回true // CHECKERDIM / 2為半徑 return (cox - x) * (cox - x) + (coy - y) * (coy - y) CHECKERDIM / 2 * CHECKERDIM / 2; } public void mouseReleased (MouseEvent e) { // When mouse is released, clear inDrag (to // indicate no drag in progress) if inDrag is // already set. // 當(dāng)鼠標(biāo)按鍵被釋放時(shí),如果inDrag已經(jīng)為true, // 則將其置為false(用來表明不在拖動(dòng)過程中) if (inDrag) inDrag = false; } }); // Attach a mouse motion listener to the applet. That listener listens // for mouse drag events. //向applet添加一個(gè)用來監(jiān)聽鼠標(biāo)拖動(dòng)事件的鼠標(biāo)運(yùn)動(dòng)監(jiān)聽器 addMouseMotionListener (new MouseMotionAdapter () { public void mouseDragged (MouseEvent e) { if (inDrag) { // Calculate draggable checker's new // origin (the upper-left corner of // the checker rectangle). // 計(jì)算棋子新的原點(diǎn)(棋子矩形的左上角) int tmpox = e.getX () - relx; int tmpoy = e.getY () - rely; // If the checker is not being moved // (at least partly) off board, // assign the previously calculated // origin (tmpox, tmpoy) as the // permanent origin (ox, oy), and // redraw the display area (with the // draggable checker at the new // coordinates). // 如果棋子(至少是棋子的一部分)沒有被 // 移出棋盤,則將之前計(jì)算的原點(diǎn) // (tmpox, tmpoy)賦值給永久性的原點(diǎn)(ox, oy), // 并且刷新顯示區(qū)域(此時(shí)的棋子已經(jīng)位于新坐標(biāo)上) if (tmpox boardx tmpoy boardy tmpox + CHECKERDIM boardx + BOARDDIM tmpoy + CHECKERDIM boardy + BOARDDIM) { ox = tmpox; oy = tmpoy; repaint (); } } } }); } public void paint (Graphics g) { // Paint the checkerboard over which the checker will be dragged. // 在棋子將要被拖動(dòng)的位置上繪制棋盤 paintCheckerBoard (imG, boardx, boardy); // Paint the checker that will be dragged. // 繪制即將被拖動(dòng)的棋子 paintChecker (imG, ox, oy); // Draw contents of image buffer. // 繪制圖像緩沖的內(nèi)容 g.drawImage (imBuffer, 0, 0, this); } void paintChecker (Graphics g, int x, int y) { // Set checker shadow color. // 設(shè)置棋子陰影的顏色 g.setColor (Color.black); // Paint checker shadow. // 繪制棋子的陰影 g.fillOval (x, y, CHECKERDIM, CHECKERDIM); // Set checker color. // 設(shè)置棋子顏色 g.setColor (Color.red); // Paint checker. // 繪制棋子 g.fillOval (x, y, CHECKERDIM - CHECKERDIM / 13, CHECKERDIM - CHECKERDIM / 13); } void paintCheckerBoard (Graphics g, int x, int y) { // Paint checkerboard outline. // 繪制棋盤輪廓線 g.setColor (Color.black); g.drawRect (x, y, 8 * SQUAREDIM + 1, 8 * SQUAREDIM + 1); // Paint checkerboard. // 繪制棋盤 for (int row = 0; row 8; row++) { g.setColor (((row 1) != 0) ? darkGreen : Color.white); for (int col = 0; col 8; col++) { g.fillRect (x + 1 + col * SQUAREDIM, y + 1 + row * SQUAREDIM, SQUAREDIM, SQUAREDIM); g.setColor ((g.getColor () == darkGreen) ? Color.white : darkGreen); } } } // The AWT invokes the update() method in response to the repaint() method // calls that are made as a checker is dragged. The default implementation // of this method, which is inherited from the Container class, clears the // applet's drawing area to the background color prior to calling paint(). // This clearing followed by drawing causes flicker. CheckerDrag overrides // update() to prevent the background from being cleared, which eliminates // the flicker. // AWT調(diào)用了update()方法來響應(yīng)拖動(dòng)棋子時(shí)所調(diào)用的repaint()方法。該方法從 // Container類繼承的默認(rèn)實(shí)現(xiàn)會(huì)在調(diào)用paint()之前,將applet的繪圖區(qū)域清除 // 為背景色,這種繪制之后的清除就導(dǎo)致了閃爍。CheckerDrag重寫了update()來 // 防止背景被清除,從而消除了閃爍。 public void update (Graphics g) { paint (g); }}

Java實(shí)驗(yàn),代碼怎么寫?

Shape.java接口代碼

public interface Shape {

public static final double PI = 3.14d;

public double area();

}

Circle.java圓類代碼

public class Circle implements Shape {

private double radius;

public Circle(double radius) {

? this.radius = radius;

}

@Override

public double area() {

? return PI * this.radius * this.radius;

}

public double perimeter() {

? return 2 * PI * this.radius;

}

}

Cylinder.java圓柱體類代碼

public class Cylinder extends Circle {

private double height;

public Cylinder(double radius, double height) {

? super(radius);

? this.height = height;

}

public double area() {

? return 2 * super.area() + super.perimeter() * this.height;

}

public double volume() {

? return super.area() * this.height;

}

}

X5_3_6.java主類代碼

public class X5_3_6 {

public static void main(String[] args) {

? Circle cir1 = new Circle(5);

? System.out.println("圓的面積為:" + cir1.area());

? System.out.println("圓的周長為:" + cir1.perimeter());

? Cylinder cy1 = new Cylinder(10, 15);

? System.out.println("圓柱體的表面積為:" + cy1.area());

? System.out.println("圓柱體的體積為:" + cy1.volume());

}

}

上面是我寫的代碼,下圖是執(zhí)行結(jié)果,麻煩看一下,是否可以。

跪地求好玩的JAVA 源代碼~

連連看java源代碼

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class lianliankan implements ActionListener

{

JFrame mainFrame; //主面板

Container thisContainer;

JPanel centerPanel,southPanel,northPanel; //子面板

JButton diamondsButton[][] = new JButton[6][5];//游戲按鈕數(shù)組

JButton exitButton,resetButton,newlyButton; //退出,重列,重新開始按鈕

JLabel fractionLable=new JLabel("0"); //分?jǐn)?shù)標(biāo)簽

JButton firstButton,secondButton; //分別記錄兩次被選中的按鈕

int grid[][] = new int[8][7];//儲(chǔ)存游戲按鈕位置

static boolean pressInformation=false; //判斷是否有按鈕被選中

int x0=0,y0=0,x=0,y=0,fristMsg=0,secondMsg=0,validateLV; //游戲按鈕的位置坐標(biāo)

int i,j,k,n;//消除方法控制

public void init(){

mainFrame=new JFrame("JKJ連連看");

thisContainer = mainFrame.getContentPane();

thisContainer.setLayout(new BorderLayout());

centerPanel=new JPanel();

southPanel=new JPanel();

northPanel=new JPanel();

thisContainer.add(centerPanel,"Center");

thisContainer.add(southPanel,"South");

thisContainer.add(northPanel,"North");

centerPanel.setLayout(new GridLayout(6,5));

for(int cols = 0;cols 6;cols++){

for(int rows = 0;rows 5;rows++ ){

diamondsButton[cols][rows]=new JButton(String.valueOf(grid[cols+1][rows+1]));

diamondsButton[cols][rows].addActionListener(this);

centerPanel.add(diamondsButton[cols][rows]);

}

}

exitButton=new JButton("退出");

exitButton.addActionListener(this);

resetButton=new JButton("重列");

resetButton.addActionListener(this);

newlyButton=new JButton("再來一局");

newlyButton.addActionListener(this);

southPanel.add(exitButton);

southPanel.add(resetButton);

southPanel.add(newlyButton);

fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable.getText())));

northPanel.add(fractionLable);

mainFrame.setBounds(280,100,500,450);

mainFrame.setVisible(true);

}

public void randomBuild() {

int randoms,cols,rows;

for(int twins=1;twins=15;twins++) {

randoms=(int)(Math.random()*25+1);

for(int alike=1;alike=2;alike++) {

cols=(int)(Math.random()*6+1);

rows=(int)(Math.random()*5+1);

while(grid[cols][rows]!=0) {

cols=(int)(Math.random()*6+1);

rows=(int)(Math.random()*5+1);

}

this.grid[cols][rows]=randoms;

}

}

}

public void fraction(){

fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable.getText())+100));

}

public void reload() {

int save[] = new int[30];

int n=0,cols,rows;

int grid[][]= new int[8][7];

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

for(int j=0;j=5;j++) {

if(this.grid[i][j]!=0) {

save[n]=this.grid[i][j];

n++;

}

}

}

n=n-1;

this.grid=grid;

while(n=0) {

cols=(int)(Math.random()*6+1);

rows=(int)(Math.random()*5+1);

while(grid[cols][rows]!=0) {

cols=(int)(Math.random()*6+1);

rows=(int)(Math.random()*5+1);

}

this.grid[cols][rows]=save[n];

n--;

}

mainFrame.setVisible(false);

pressInformation=false; //這里一定要將按鈕點(diǎn)擊信息歸為初始

init();

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

for(int j = 0;j 5;j++ ){

if(grid[i+1][j+1]==0)

diamondsButton[i][j].setVisible(false);

}

}

}

public void estimateEven(int placeX,int placeY,JButton bz) {

if(pressInformation==false) {

x=placeX;

y=placeY;

secondMsg=grid[x][y];

secondButton=bz;

pressInformation=true;

}

else {

x0=x;

y0=y;

fristMsg=secondMsg;

firstButton=secondButton;

x=placeX;

y=placeY;

secondMsg=grid[x][y];

secondButton=bz;

if(fristMsg==secondMsg secondButton!=firstButton){

xiao();

}

}

}

public void xiao() { //相同的情況下能不能消去。仔細(xì)分析,不一條條注釋

if((x0==x (y0==y+1||y0==y-1)) || ((x0==x+1||x0==x-1)(y0==y))){ //判斷是否相鄰

remove();

}

else{

for (j=0;j7;j++ ) {

if (grid[x0][j]==0){ //判斷第一個(gè)按鈕同行哪個(gè)按鈕為空

if (yj) { //如果第二個(gè)按鈕的Y坐標(biāo)大于空按鈕的Y坐標(biāo)說明第一按鈕在第二按鈕左邊

for (i=y-1;i=j;i-- ){ //判斷第二按鈕左側(cè)直到第一按鈕中間有沒有按鈕

if (grid[x][i]!=0) {

k=0;

break;

}

else{ k=1; } //K=1說明通過了第一次驗(yàn)證

}

if (k==1) {

linePassOne();

}

}

if (yj){ //如果第二個(gè)按鈕的Y坐標(biāo)小于空按鈕的Y坐標(biāo)說明第一按鈕在第二按鈕右邊

for (i=y+1;i=j ;i++ ){ //判斷第二按鈕左側(cè)直到第一按鈕中間有沒有按鈕

if (grid[x][i]!=0){

k=0;

break;

}

else { k=1; }

}

if (k==1){

linePassOne();

}

}

if (y==j ) {

linePassOne();

}

}

if (k==2) {

if (x0==x) {

remove();

}

if (x0x) {

for (n=x0;n=x-1;n++ ) {

if (grid[n][j]!=0) {

k=0;

break;

}

if(grid[n][j]==0 n==x-1) {

remove();

}

}

}

if (x0x) {

for (n=x0;n=x+1 ;n-- ) {

if (grid[n][j]!=0) {

k=0;

break;

}

if(grid[n][j]==0 n==x+1) {

remove();

}

}

}

}

}

for (i=0;i8;i++ ) { //列

if (grid[i][y0]==0) {

if (xi) {

for (j=x-1;j=i ;j-- ) {

if (grid[j][y]!=0) {

k=0;

break;

}

else { k=1; }

}

if (k==1) {

rowPassOne();

}

}

if (xi) {

for (j=x+1;j=i;j++ ) {

if (grid[j][y]!=0) {

k=0;

break;

}

else { k=1; }

}

if (k==1) {

rowPassOne();

}

}

if (x==i) {

rowPassOne();

}

}

if (k==2){

if (y0==y) {

remove();

}

if (y0y) {

for (n=y0;n=y-1 ;n++ ) {

if (grid[i][n]!=0) {

k=0;

break;

}

if(grid[i][n]==0 n==y-1) {

remove();

}

}

}

if (y0y) {

for (n=y0;n=y+1 ;n--) {

if (grid[i][n]!=0) {

k=0;

break;

}

if(grid[i][n]==0 n==y+1) {

remove();

}

}

}

}

}

}

}

public void linePassOne(){

if (y0j){ //第一按鈕同行空按鈕在左邊

for (i=y0-1;i=j ;i-- ){ //判斷第一按鈕同左側(cè)空按鈕之間有沒按鈕

if (grid[x0][i]!=0) {

k=0;

break;

}

else { k=2; } //K=2說明通過了第二次驗(yàn)證

}

}

if (y0j){ //第一按鈕同行空按鈕在與第二按鈕之間

for (i=y0+1;i=j ;i++){

if (grid[x0][i]!=0) {

k=0;

break;

}

else{ k=2; }

}

}

}

public void rowPassOne(){

if (x0i) {

for (j=x0-1;j=i ;j-- ) {

if (grid[j][y0]!=0) {

k=0;

break;

}

else { k=2; }

}

}

if (x0i) {

for (j=x0+1;j=i ;j++ ) {

if (grid[j][y0]!=0) {

k=0;

break;

}

else { k=2; }

}

}

}

public void remove(){

firstButton.setVisible(false);

secondButton.setVisible(false);

fraction();

pressInformation=false;

k=0;

grid[x0][y0]=0;

grid[x][y]=0;

}

public void actionPerformed(ActionEvent e) {

if(e.getSource()==newlyButton){

int grid[][] = new int[8][7];

this.grid = grid;

randomBuild();

mainFrame.setVisible(false);

pressInformation=false;

init();

}

if(e.getSource()==exitButton)

System.exit(0);

if(e.getSource()==resetButton)

reload();

for(int cols = 0;cols 6;cols++){

for(int rows = 0;rows 5;rows++ ){

if(e.getSource()==diamondsButton[cols][rows])

estimateEven(cols+1,rows+1,diamondsButton[cols][rows]);

}

}

}

public static void main(String[] args) {

lianliankan llk = new lianliankan();

llk.randomBuild();

llk.init();

}

}

//old 998 lines

//new 318 lines

基于JAVA的3D坦克游戲源代碼

JAVA猜數(shù)字小游戲源代碼

/*1、編寫一個(gè)猜數(shù)字的游戲,由電腦隨機(jī)產(chǎn)生一個(gè)100以內(nèi)的整數(shù),讓用戶去猜,如果用戶猜的比電腦大,則輸出“大了,再小點(diǎn)!”,反之則輸出“小了,再大點(diǎn)!”,用戶總共只能猜十次,并根據(jù)用戶正確猜出答案所用的次數(shù)輸出相應(yīng)的信息,如:只用一次就猜對(duì),輸出“你是個(gè)天才!”,八次才猜對(duì),輸出“笨死了!”,如果十次還沒有猜對(duì),則游戲結(jié)束!*/

import java.util.*;

import java.io.*;

public class CaiShu{

public static void main(String[] args) throws IOException{

Random a=new Random();

int num=a.nextInt(100);

System.out.println("請(qǐng)輸入一個(gè)100以內(nèi)的整數(shù):");

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

BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));

String str=bf.readLine();

int shu=Integer.parseInt(str);

if (shunum)

System.out.println("輸入的數(shù)大了,輸小點(diǎn)的!");

else if (shunum)

System.out.println("輸入的數(shù)小了,輸大點(diǎn)的!");

else {

System.out.println("恭喜你,猜對(duì)了!");

if (i=2)

System.out.println("你真是個(gè)天才!");

else if (i=6)

System.out.println("還將就,你過關(guān)了!");

else if (i=8)

System.out.println("但是你還……真笨!");

else

System.out.println("你和豬沒有兩樣了!");

break;}

}

}

}

幫忙寫下Java代碼

你好,按照你的要求補(bǔ)充的代碼如下

// 【代碼1】 // 實(shí)現(xiàn)totalSalesByYear( )方法

public double totalSalesByYear() {

return 5000;

}

// 【代碼2】 // 實(shí)現(xiàn)totalSalesByYear( )方法

public double totalSalesByYear() {

return 3000;

}

// 【代碼3】 // 實(shí)現(xiàn)totalSalesByYear( )方法

public double totalSalesByYear() {

return 1000;

}

// 【代碼4】 // 計(jì)算商店年銷售額totalSales

for (ComputeTotalSales good : goods) {

totalSales += good.totalSalesByYear();

}


網(wǎng)站標(biāo)題:java帥氣代碼 java酷炫代碼
本文URL:http://weahome.cn/article/hjjiid.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部