JAVA代码卖的 java 代码大全

求一个简单的JAVA游戏代码,100行左右,谢谢!import java.awt.Dimension;
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();
【JAVA代码卖的 java 代码大全】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; i4; 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; i5; 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(radius200)
radius += 2;
repaint();
} else if(e.getActionCommand() == "-") {
if(radius0)
radius -= 2;
repaint();
} else if(e.getActionCommand() == "R") {
degree = (degree + 2) % 360;
repaint();
} else if(e.getActionCommand() == "L") {
degree = (degree - 2) % 360;
repaint();
}
}
}
java中两种占位符的使用方式String stringFormat= "lexical error at position %s, encountered %s, expected %s ";
System.out.println(String.format(stringFormat, 123, 100, 456));
String messageFormat ="lexical error at position {0}, encountered {1}, expected {2}";
System.out.println(MessageFormat.format(messageFormat, new Date(), 100, 456));
先学现卖 哈哈
求Java代码使用循环结构,通过Scanner类从控制台输入每个人JAVA代码卖的的捐款金额,并累加每个人JAVA代码卖的的捐款金额,计算捐款总数和捐款人数,如果捐款总数达到10万元,则计算平均每人捐款金额 。
下面是通过输入进行统计,实际过程中还能是通过数据库进行操作,或者表格收集数据进行导入关系数据库进行统计 。还可以通过接入微信或者支付宝小程序收款实时统计 。
已经有人给过随机数示例,这里给出前端输入的示例JAVA代码卖的:
import java.util.Scanner;
public class CharityDonation {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int num = 0;// 捐款人数
int total = 0;// 募捐总数
int avg = 0;// 平均每人捐款金额
int donation;// 每个人的捐款金额
while (total100000num1000) {
System.out.print("请输入第" + (num + 1) + "个人的捐款金额JAVA代码卖的:");
donation = scanner.nextInt();

推荐阅读