拉霸機
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
int a1 = 0, d1, randnum1 = 10, randnum2 = 10, randnum3 = 10;
int a2 = 0, d2, a3 = 0, d3;
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
a1++;
d1 = a1 % 10;
if (a1 >= randnum1)
{
timer1.Enabled = false;
}
button1.Text = d1.ToString();
if ((randnum1 == randnum2) && (randnum2 == randnum3))
MessageBox.Show("Win");
}
private void button1_Click(object sender, EventArgs e)
{
}
private void button4_Click(object sender, EventArgs e)
{
a1 = 0;
a2 = 0;
a3 = 0;
timer1.Enabled = true;
timer2.Enabled = true;
timer3.Enabled = true;
Random rnd = new Random();
randnum1 = rnd.Next(1, 10);
randnum2 = rnd.Next(1, 10);
randnum3 = rnd.Next(1, 10);
//randnum2 = randnum1 + randnum2;
//randnum3 = randnum1 + randnum2 + randnum3;
}
private void timer2_Tick(object sender, EventArgs e)
{
a2++;
d2 = a2 % 10;
if (a2 >= randnum2)
{
timer2.Enabled = false;
}
button2.Text = d2.ToString();
}
private void timer3_Tick(object sender, EventArgs e)
{
a3++;
d3 = a3 % 10;
if (a3 >= randnum3)
{
timer3.Enabled = false;
}
button3.Text = d3.ToString();
}
private void timer4_Tick(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
qaz203540 發表在 痞客邦 留言(0) 人氣()
using System;
using System.Collections.Generic;
qaz203540 發表在 痞客邦 留言(0) 人氣()
qaz203540 發表在 痞客邦 留言(0) 人氣()
import java.util.Random;
import java.awt.*;
qaz203540 發表在 痞客邦 留言(0) 人氣()
import java.util.Random;
import java.awt.*;
qaz203540 發表在 痞客邦 留言(0) 人氣()
qaz203540 發表在 痞客邦 留言(0) 人氣()
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Test
{
public static void main(String[] args)
{
JFrame jtfMainFrame = new JFrame("Which Button Demo");
jtfMainFrame.setSize(600, 200);
JPanel jplPanel = new JPanel();
int i;
int j=1;
int num1 , num2;
JButton jbnButton[] = new JButton[16];
JButton changeButton[] = new JButton[3];
jplPanel.setLayout (new GridLayout(4, 4));
for(i = 0;i<=15;i++){
jbnButton[i]=new JButton("Button"+(i+1));
jplPanel.add(jbnButton[i]);
String s = Integer.toString(i+1);
jbnButton[i].addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
/*if(j<3){
changeButton[j] = jbnButton[i];
num1 = i;
j++;
}
else if(j==3){
changeButton[j]=jbnButton[i];
jbnButton[num1] = changeButton[j];
jbnButton[i] = changeButton[j-1];
j=1;
}*/
//j++;
//JButton btn = (JButton[i])e.getSourec();
//lab.setText(btn.getLabel+".");
System.out.println("Button"+s);
}
});
}
jtfMainFrame.getContentPane().add(jplPanel, BorderLayout.CENTER);
jtfMainFrame.setVisible(true);
}
}
qaz203540 發表在 痞客邦 留言(0) 人氣()
import java.awt.*;
import java.awt.event.*;
qaz203540 發表在 痞客邦 留言(0) 人氣()
qaz203540 發表在 痞客邦 留言(0) 人氣()
import java.awt.*; import java.awt.event.*; import javax.swing.*; class test { public static void main(String[] args) { JFrame jtfMainFrame = new JFrame("安安"); jtfMainFrame.setSize(300, 250); JButton jbnButton1 = new JButton("Button 1"); JButton jbnButton2 = new JButton("Button 2"); JButton jbnButton3 = new JButton("Button 3"); JButton jbnButton4 = new JButton("Button 4"); JButton jbnButton5 = new JButton("Button 5"); JButton jbnButton6 = new JButton("Button 6"); JButton jbnButton7 = new JButton("Button 7"); JButton jbnButton8 = new JButton("Button 8"); JButton jbnButton9 = new JButton("Button 9"); JTextField jtfInput = new JTextField(20); JPanel jplPanel = new JPanel(); jplPanel.add(jtfInput); jplPanel.add(jbnButton1); jbnButton1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jtfInput.setText("Button 1!"); } }); jplPanel.add(jbnButton2); jbnButton2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jtfInput.setText("Button 2!"); } }); jplPanel.add(jbnButton3); jbnButton3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jtfInput.setText("Button 3!"); } }); jplPanel.add(jbnButton4); jbnButton4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jtfInput.setText("Button 4!"); } }); jplPanel.add(jbnButton5); jbnButton5.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jtfInput.setText("Button 5!"); } }); jplPanel.add(jbnButton6); jbnButton6.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jtfInput.setText("Button 6!"); } }); jplPanel.add(jbnButton7); jbnButton7.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jtfInput.setText("Button 7!"); } }); jplPanel.add(jbnButton8); jbnButton8.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jtfInput.setText("Button 8!"); } }); jplPanel.add(jbnButton9); jbnButton9.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jtfInput.setText("Button 9!"); } }); jtfMainFrame.getContentPane().add(jplPanel, BorderLayout.CENTER); jtfMainFrame.setVisible(true); System.out.print("Feng-Chia"); } }
qaz203540 發表在 痞客邦 留言(0) 人氣()
qaz203540 發表在 痞客邦 留言(0) 人氣()
1.為何why要選修這門課(動機)
想要學分並學習程式方便的課
qaz203540 發表在 痞客邦 留言(0) 人氣()