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

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

java代碼精品 高質(zhì)量java代碼

求一個(gè)簡單的JAVA游戲代碼,100行左右,謝謝!

import java.awt.Dimension;

目前成都創(chuàng)新互聯(lián)公司已為上1000+的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬空間、網(wǎng)站托管運(yùn)營、企業(yè)網(wǎng)站設(shè)計(jì)、鯉城網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。

import java.awt.Graphics;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JPanel;

public class Painter extends JFrame{

/**

*

*/

private static final long serialVersionUID = 8160427604782702376L;

CanvasPanel canvas = new CanvasPanel();;

public Painter() {

super("Star");

this.add(canvas);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

this.pack();

this.setResizable(false);

this.setLocationRelativeTo(null);

this.setVisible(true);

}

public static void main(String[] args) {

new Painter();

}

}

class CanvasPanel extends JPanel implements ActionListener{

/**

*

*/

private static final long serialVersionUID = -4642528854538741028L;

private JButton[] btn = new JButton[4];

private String[] btn_name = {"+", "-", "R", "L"};

private int center_x = 200, center_y = 200, radius = 100, degree = 0;

public CanvasPanel() {

this.setPreferredSize(new Dimension(400, 500));

this.setLayout(null);

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

btn[i] = new JButton(btn_name[i]);

btn[i].setBounds(160 + i * 60, 425, 50, 50);

btn[i].addActionListener(this);

this.add(btn[i]);

}

}

@Override

public void paintComponent(Graphics g) {

super.paintComponent(g);

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

g.drawLine( (int) (center_x + radius * Math.sin(Math.toRadians(degree + 72 * i))),

(int) (center_y - radius * Math.cos(Math.toRadians(degree + 72 * i))),

(int) (center_x + radius * Math.sin(Math.toRadians(degree + 72 * i + 144))),

(int) (center_y - radius * Math.cos(Math.toRadians(degree + 72 * i + 144))));

}

}

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

if(e.getActionCommand() == "+") {

if(radius 200)

radius += 2;

repaint();

} else if(e.getActionCommand() == "-") {

if(radius 0)

radius -= 2;

repaint();

} else if(e.getActionCommand() == "R") {

degree = (degree + 2) % 360;

repaint();

} else if(e.getActionCommand() == "L") {

degree = (degree - 2) % 360;

repaint();

}

}

}

求這段JAVA程序代碼

//Example.java

class A{

float a;

static float b;

void setA(float a ){

this.a = a;

}

void setB(float b){

this.b = b;

}

float getA() {

return a;

}

float getB() {

return b;

}

void inputA() {

System.out.println(a);

}

static void inputB() {

System.out.println(b);

}

}

public class Example {

public static void main (String args[]){

/*代碼5] //通過類名操作類變量b,并賦值100

[代碼6] //通過類名調(diào)用方法inputB()

A cat=new A();

A dog=new A();

[代碼7] //cat調(diào)用方法setA(int a)將cat的成員a的值設(shè)置為200

[代碼8] //cat調(diào)用方法setB(int b)將cat的成員b的值設(shè)置為400

[代碼9] //dog調(diào)用方法setA(int a)將dog的成員a的值設(shè)置為300

[代碼10] //dog調(diào)用方法setB(int b)將dog的成員b的值設(shè)置為800

[代碼11] //cat調(diào)用方法inputA()

[代碼12] //cat調(diào)用方法inputB()

[代碼13] //dog調(diào)用方法inputA()

[代碼14] //dog調(diào)用方法inputB()*/

A.b = 100;

A.inputB();

A cat = new A();

A dog = new A();

cat.setA(200);

cat.setB(300);

dog.setA(300);

dog.setB(800);

cat.inputA();

cat.inputB();

dog.inputA();

dog.inputB();

}

}

有一個(gè)要說明的是,setA()與setB()的形參是浮點(diǎn)型的,所以如樓上所說,樓主代碼7到代碼10的形參設(shè)錯(cuò)了。但200,400,300,800是可以的。只是將int改為float.

誰能給一個(gè)Java程序代碼我,要50行到100行就可以啦。最好有幾行解釋

給你一個(gè)前幾天才幫人寫的

“計(jì)算整錢兌零”。程序要求用戶輸入一個(gè)雙精度數(shù)代表總元數(shù),就會(huì)列出總值與其等價(jià)的1元幣、二角五分幣、5分幣和1分幣的數(shù)目。程序報(bào)告的數(shù)目是1元幣的最大數(shù)、其次是二角五分幣的最大數(shù),等等,依此類推。只顯示非零的單位。對單個(gè)單位顯示單數(shù)單詞,對多于一個(gè)單位的顯示復(fù)數(shù)單詞

import java.util.Scanner;

public class MoneyCalculate {

public static void main(String[] args) {

int max100 = 0;

int max25 = 0;

int max5 = 0;

int max1 = 0;

double money = getMoneyFromInput();

String str = String.valueOf(money).trim();

String[] ary = str.split("\\.");

max100 = Integer.parseInt(ary[0]);

if(ary.length == 2){

int fen = Integer.parseInt(ary[1]);

if(ary[1].trim().length() == 1){

fen = Integer.parseInt(ary[1]) * 10;

}

max25 = fen / 25;

if(fen % 25 != 0){

fen = fen % 25;

}else{

fen = 0;

}

max5 = fen / 5;

max1 = fen % 5;

}

StringBuilder sb = new StringBuilder(money + " = ");

if(max100 != 0){

sb.append(max100);

sb.append("*1 ");

}

if(max25 != 0){

sb.append(max25);

sb.append("*0.25 ");

}

if(max5 != 0){

sb.append(max5);

sb.append("*0.05 ");

}

if(max1 != 0){

sb.append(max1);

sb.append("*0.01 ");

}

System.out.println(sb.toString());

}

private static double getMoneyFromInput() {

Scanner scanner = new Scanner(System.in);

return scanner.nextDouble();

}

}

-----------

2.49

2.49 = 2*1 1*0.25 4*0.05 4*0.01

-----------

2.5

2.5 = 2*1 2*0.25

-----------

37.23

37.23 = 37*1 4*0.05 3*0.01

-----------------

123.569

123.569 = 123*1 22*0.25 3*0.05 4*0.01


網(wǎng)頁標(biāo)題:java代碼精品 高質(zhì)量java代碼
URL鏈接:http://weahome.cn/article/dddghjg.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部