java人生模拟代码 java职业规划

怎么用java代码模拟一张图片用java代码模拟一张图片可以这样操作java人生模拟代码:1.创建BufferedImage类
2.根据BufferedImage类得到一个Graphics2D对象
3.根据Graphics2D对象进行逻辑操作
4.处理绘图
5.将绘制好java人生模拟代码的图片写入到图片
用java代码写人生 int s = 人的生命的开始; int o = 人的生命的结束; foint 后面不能跟字符串 。。并且for循环也不知道想要表达什么
public class Test {
public static void main(String[] args) {
double b = Math.random() * 50;
int a = (int) b + 50;
for (int i = 0; i = a; i++) {
if (i == 0) {
System.out.println("出生!");
} else {
System.out.println(i + "岁了!");
}
}
}
}
求一个简单的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();
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));
【java人生模拟代码 java职业规划】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代码 模拟简易atm机参考了别人的代码 。略作修改 , 已经很简单了:
InfoATM.java:
public class InfoATM {
double money = 0;
public InfoATM(double cash) {
super();
this.money = cash;
}
// 存款的方法
public void save(double count) {
money += count;
}
// 取款的方法
public void draw(double count) {
money -= count;
}
public double getMoney() {
return money;
}
public void setMoney(double money) {
this.money = money;
}
}

推荐阅读