java大转盘代码 java大转盘抽奖
求Java实现转盘转动功能,抽奖,坐等
转盘转动就是图片,定义一个随机数random;
成都创新互联公司长期为上千多家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为舒兰企业提供专业的成都网站设计、网站建设,舒兰网站改版等技术服务。拥有10年丰富建站经验和众多成功案例,为您定制开发。
if(random==1){
画中奖的图片
}else{
画不中奖的图片}
求一个简单的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));
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程序代码?
class A
{
//声明一个float型实例变量a
//声明一个float型类变量b,即static变量b
private float a;
private static float b;
void setA(float a)
{
//将参数a的值赋值给成员变量a
this.a = a;
}
void setB(float b)
{
//将参数b的值赋值给成员变量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[])
{
//通过类名操作类变量b,并赋值100
//通过类名调用方法inputB()
A.b = 100;
A.inoutB();
A cat=new A();
A dog=new A();
//cat调用方法setA(int a)将cat的成员 a的值设置为200
cat.setA(200);
// cat调用方法setB(int B)将cat的成员 b的值设置400
cat.setB(400);
//dog调用方法setA(int a)将dog的成员 a的值设置为150
dog.setA(150);
//dog调用方法setB(int b)将dog的成员 b的值设置为300
dog.setB(300);
//cat调用inputA()
//cat调用inputB()
//dog调用inputA()
//dog调用inputB()
cat.inputA();
cat.inputB();
dog.inputA();
dog.inputB();
}
}
Java编写代码,在D盘下创建abc文件夹,然后在abc文件夹中创建abc文件,求详细代码?!
Java代码:
import java.io.File;
import java.io.IOException;
public class Test10 {
public static void main(String[] args) {
//创建“abc”文件夹
String pathName = "d:\\abc";
File path = new File(pathName);
path.mkdir();
//创建“abc”文件
String fileName = "d:\\abc\\abc";
File file = new File(fileName);
try {
file.createNewFile();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
新闻标题:java大转盘代码 java大转盘抽奖
转载注明:http://myzitong.com/article/dogjigj.html