<html>
<head>
<title>期末2</title>
</head>
<body>
<script>
var balls = new Array(10);
var i=0,j=0,k=0;
for(i=0;i<10;i++)
{
balls[i]=i+1;
}
for(i=1;i<=1000;i++)
{
j=Math.floor(Math.random()*9);
k=Math.floor(Math.random()*9);
balls[49]=balls[j];
balls[j]=balls[k];
balls[k]=balls[49];
}
document.write(balls[0]+","+balls[1]+","+balls[2]);
</script>
</body>
</html>
2016年6月3日 星期五
2016年5月20日 星期五
亂數圓餅圖 5.20
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
var a,b,c;
var n1,n2,n3,n4;
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function Ran(){
n1 = 0;
n2 = 0;
n3 = 0;
n4 = 0;
var maxNum = 10;
var minNum = 0;
n1 = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
n2 = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
n3 = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
n4 = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
drawChart();
}
function add() {
a=0;
b=0;
c=0;
var radio1 = document.getElementsByName("v1");
var radio2 = document.getElementsByName("v2");
var radio3 = document.getElementsByName("v3");
for(var i=0;i<radio1.length;i++)
{
if(radio1.item(i).checked==true)
{
i = i+1
alert(i);
if (i==1)
{
a=a+1;
}
if (i==2)
{
b=b+1;
}
if (i==3)
{
c=c+1;
}
}}
for(var i=0;i<radio2.length;i++)
{
if(radio2.item(i).checked==true)
{
i = i+1
alert(i);
if (i==1)
{
a=a+1;
}
if (i==2)
{
b=b+1;
}
if (i==3)
{
c=c+1;
}
}}
for(var i=0;i<radio3.length;i++)
{
if(radio3.item(i).checked==true)
{
i = i+1
alert(i);
if (i==1)
{
a=a+1;
}
if (i==2)
{
b=b+1;
}
if (i==3)
{
c=c+1;
}
}}
document.getElementById('c1').value=a;
document.getElementById('c2').value=b;
document.getElementById('c3').value=c;
drawChart();
}
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Task', 'Hours per Day'],
['A', n1],
['B', n2],
['C', n3],
['D', n4],
]);
var options = {
title: 'My Daily Activities'
};
var chart = new google.visualization.PieChart(document.getElementById('piechart'));
chart.draw(data, options);
}
</script>
</head>
<body>
<h1>你選了什麼?</h1>
<input name="v1" type="radio" value="300年>300年
<input name="v1" type="radio" value="400年>400年
<input name="v1" type="radio" value="1000年>1000年
<br>
<h1>你選了什麼?</h1>
<input name="v2" type="radio" value="300年>300年
<input name="v2" type="radio" value="400年>400年
<input name="v2" type="radio" value="1000年>1000年
<br>
<h1>你選了什麼?</h1>
<input name="v3" type="radio" value="300年>300
<input name="v3" type="radio" value="400年>400年
<input name="v3" type="radio" value="1000年>1000年
<br>
Section1:
<input type="text" name="FirstName" id="c1" <br><br/>
Section2:
<input type="text" name="address" id="c2" <br></br>
Section3:
<input type="text" name="address" id="c3" <br></br>
<input type="button" value="submit" onclick="add()"/>
<input type="button" value="Randon" onclick="Ran()"/>
<div id="piechart" style="width: 900px; height: 500px;"></div>
</body>
</html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
var a,b,c;
var n1,n2,n3,n4;
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function Ran(){
n1 = 0;
n2 = 0;
n3 = 0;
n4 = 0;
var maxNum = 10;
var minNum = 0;
n1 = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
n2 = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
n3 = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
n4 = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum;
drawChart();
}
function add() {
a=0;
b=0;
c=0;
var radio1 = document.getElementsByName("v1");
var radio2 = document.getElementsByName("v2");
var radio3 = document.getElementsByName("v3");
for(var i=0;i<radio1.length;i++)
{
if(radio1.item(i).checked==true)
{
i = i+1
alert(i);
if (i==1)
{
a=a+1;
}
if (i==2)
{
b=b+1;
}
if (i==3)
{
c=c+1;
}
}}
for(var i=0;i<radio2.length;i++)
{
if(radio2.item(i).checked==true)
{
i = i+1
alert(i);
if (i==1)
{
a=a+1;
}
if (i==2)
{
b=b+1;
}
if (i==3)
{
c=c+1;
}
}}
for(var i=0;i<radio3.length;i++)
{
if(radio3.item(i).checked==true)
{
i = i+1
alert(i);
if (i==1)
{
a=a+1;
}
if (i==2)
{
b=b+1;
}
if (i==3)
{
c=c+1;
}
}}
document.getElementById('c1').value=a;
document.getElementById('c2').value=b;
document.getElementById('c3').value=c;
drawChart();
}
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Task', 'Hours per Day'],
['A', n1],
['B', n2],
['C', n3],
['D', n4],
]);
var options = {
title: 'My Daily Activities'
};
var chart = new google.visualization.PieChart(document.getElementById('piechart'));
chart.draw(data, options);
}
</script>
</head>
<body>
<h1>你選了什麼?</h1>
<input name="v1" type="radio" value="300年>300年
<input name="v1" type="radio" value="400年>400年
<input name="v1" type="radio" value="1000年>1000年
<br>
<h1>你選了什麼?</h1>
<input name="v2" type="radio" value="300年>300年
<input name="v2" type="radio" value="400年>400年
<input name="v2" type="radio" value="1000年>1000年
<br>
<h1>你選了什麼?</h1>
<input name="v3" type="radio" value="300年>300
<input name="v3" type="radio" value="400年>400年
<input name="v3" type="radio" value="1000年>1000年
<br>
Section1:
<input type="text" name="FirstName" id="c1" <br><br/>
Section2:
<input type="text" name="address" id="c2" <br></br>
Section3:
<input type="text" name="address" id="c3" <br></br>
<input type="button" value="submit" onclick="add()"/>
<input type="button" value="Randon" onclick="Ran()"/>
<div id="piechart" style="width: 900px; height: 500px;"></div>
</body>
</html>
2016年5月6日 星期五
php 在線問卷調查程序
<html>
<head>
<title>Form</title>
<script>
function check1(){
var radio1=document.getElementsByName("v1");
var radio2=document.getElementsByName("v2");
for(var i=0;i<radio1.length;i++){
if(radio1.item(i).checked==true){
var flag1 = radio1.item(i).value;
}
}
for(var j=0;j<radio2.length;j++){
if(radio2.item(j).checked==true){
var flag2 = radio2.item(j).value;
}
}
document.write("1、"+flag1+"2、"+flag2);
}
</script>
</head>
<body>
<form action="post.php" method="post" name="add" enctype="multipart/form-data" onSubmit="return check();" >
<h1>1、ssss?</h1>
<input name="v1" type="radio" value="A">A
<input name="v1" type="radio" value="B">B
<input name="v1" type="radio" value="C">C
</form>
<form action="post.php" method="post" name="add" enctype="multipart/form-data" onSubmit="return check();" >
<h1>2、WWWW?</h1>
<input name="v2" type="radio" value="A">A
<input name="v2" type="radio" value="B">B
<input name="v2" type="radio" value="C">C
<input type="button" value="submit" onclick="check1()"/>
</form>
</body>
</html>
<head>
<title>Form</title>
<script>
function check1(){
var radio1=document.getElementsByName("v1");
var radio2=document.getElementsByName("v2");
for(var i=0;i<radio1.length;i++){
if(radio1.item(i).checked==true){
var flag1 = radio1.item(i).value;
}
}
for(var j=0;j<radio2.length;j++){
if(radio2.item(j).checked==true){
var flag2 = radio2.item(j).value;
}
}
document.write("1、"+flag1+"2、"+flag2);
}
</script>
</head>
<body>
<form action="post.php" method="post" name="add" enctype="multipart/form-data" onSubmit="return check();" >
<h1>1、ssss?</h1>
<input name="v1" type="radio" value="A">A
<input name="v1" type="radio" value="B">B
<input name="v1" type="radio" value="C">C
</form>
<form action="post.php" method="post" name="add" enctype="multipart/form-data" onSubmit="return check();" >
<h1>2、WWWW?</h1>
<input name="v2" type="radio" value="A">A
<input name="v2" type="radio" value="B">B
<input name="v2" type="radio" value="C">C
<input type="button" value="submit" onclick="check1()"/>
</form>
</body>
</html>
2016年4月22日 星期五
4.22 課堂作業
摻考網址:http://pclevin.blogspot.tw/2014/12/android-studio.html
<resources> <string name="app_name">HelloWorldTest</string> <string name="action_settings">Settings</string> </resources>
2016年4月15日 星期五
eclipse連接到mysql
摻考網址:
http://blog.yslifes.com/archives/918
package db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class jdbcmysql {
private Connection con = null; //Database objects
//連接object
private Statement stat = null;
//執行,傳入之sql為完整字串
private ResultSet rs = null;
//結果集
private PreparedStatement pst = null;
//執行,傳入之sql為預儲之字申,需要傳入變數之位置
//先利用?來做標示
private String dropdbSQL = "DROP TABLE User ";
private String createdbSQL = "CREATE TABLE User (" +
" id INTEGER " +
" , name VARCHAR(20) " +
" , passwd VARCHAR(20))";
private String insertdbSQL = "insert into User(id,name,passwd) " +
"select ifNULL(max(id),0)+1,?,? FROM User";
private String selectSQL = "select * from User ";
public jdbcmysql()
{
try {
Class.forName("com.mysql.jdbc.Driver");
//註冊driver
con = DriverManager.getConnection(
"jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=Big5",
"","");
//取得connection
//jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=Big5
//localhost是主機名,test是database名
//useUnicode=true&characterEncoding=Big5使用的編碼
}
catch(ClassNotFoundException e)
{
System.out.println("DriverClassNotFound :"+e.toString());
}//有可能會產生sqlexception
catch(SQLException x) {
System.out.println("Exception :"+x.toString());
}
}
//建立table的方式
//可以看看Statement的使用方式
public void createTable()
{
try
{
stat = con.createStatement();
stat.executeUpdate(createdbSQL);
}
catch(SQLException e)
{
System.out.println("CreateDB Exception :" + e.toString());
}
finally
{
Close();
}
}
//新增資料
//可以看看PrepareStatement的使用方式
public void insertTable( String name,String passwd)
{
try
{
pst = con.prepareStatement(insertdbSQL);
pst.setString(1, name);
pst.setString(2, passwd);
pst.executeUpdate();
}
catch(SQLException e)
{
System.out.println("InsertDB Exception :" + e.toString());
}
finally
{
Close();
}
}
//刪除Table,
//跟建立table很像
public void dropTable()
{
try
{
stat = con.createStatement();
stat.executeUpdate(dropdbSQL);
}
catch(SQLException e)
{
System.out.println("DropDB Exception :" + e.toString());
}
finally
{
Close();
}
}
//查詢資料
//可以看看回傳結果集及取得資料方式
public void SelectTable()
{
try
{
stat = con.createStatement();
rs = stat.executeQuery(selectSQL);
System.out.println("ID\t\tName\t\tPASSWORD");
while(rs.next())
{
System.out.println(rs.getInt("id")+"\t\t"+
rs.getString("name")+"\t\t"+rs.getString("passwd"));
}
}
catch(SQLException e)
{
System.out.println("DropDB Exception :" + e.toString());
}
finally
{
Close();
}
}
//完整使用完資料庫後,記得要關閉所有Object
//否則在等待Timeout時,可能會有Connection poor的狀況
private void Close()
{
try
{
if(rs!=null)
{
rs.close();
rs = null;
}
if(stat!=null)
{
stat.close();
stat = null;
}
if(pst!=null)
{
pst.close();
pst = null;
}
}
catch(SQLException e)
{
System.out.println("Close Exception :" + e.toString());
}
}
public static void main(String[] args)
{
//測看看是否正常
jdbcmysql test = new jdbcmysql();
test.dropTable();
test.createTable();
test.insertTable("yku", "12356");
test.insertTable("yku2", "7890");
test.SelectTable();
}
http://blog.yslifes.com/archives/918
package db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class jdbcmysql {
private Connection con = null; //Database objects
//連接object
private Statement stat = null;
//執行,傳入之sql為完整字串
private ResultSet rs = null;
//結果集
private PreparedStatement pst = null;
//執行,傳入之sql為預儲之字申,需要傳入變數之位置
//先利用?來做標示
private String dropdbSQL = "DROP TABLE User ";
private String createdbSQL = "CREATE TABLE User (" +
" id INTEGER " +
" , name VARCHAR(20) " +
" , passwd VARCHAR(20))";
private String insertdbSQL = "insert into User(id,name,passwd) " +
"select ifNULL(max(id),0)+1,?,? FROM User";
private String selectSQL = "select * from User ";
public jdbcmysql()
{
try {
Class.forName("com.mysql.jdbc.Driver");
//註冊driver
con = DriverManager.getConnection(
"jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=Big5",
"","");
//取得connection
//jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=Big5
//localhost是主機名,test是database名
//useUnicode=true&characterEncoding=Big5使用的編碼
}
catch(ClassNotFoundException e)
{
System.out.println("DriverClassNotFound :"+e.toString());
}//有可能會產生sqlexception
catch(SQLException x) {
System.out.println("Exception :"+x.toString());
}
}
//建立table的方式
//可以看看Statement的使用方式
public void createTable()
{
try
{
stat = con.createStatement();
stat.executeUpdate(createdbSQL);
}
catch(SQLException e)
{
System.out.println("CreateDB Exception :" + e.toString());
}
finally
{
Close();
}
}
//新增資料
//可以看看PrepareStatement的使用方式
public void insertTable( String name,String passwd)
{
try
{
pst = con.prepareStatement(insertdbSQL);
pst.setString(1, name);
pst.setString(2, passwd);
pst.executeUpdate();
}
catch(SQLException e)
{
System.out.println("InsertDB Exception :" + e.toString());
}
finally
{
Close();
}
}
//刪除Table,
//跟建立table很像
public void dropTable()
{
try
{
stat = con.createStatement();
stat.executeUpdate(dropdbSQL);
}
catch(SQLException e)
{
System.out.println("DropDB Exception :" + e.toString());
}
finally
{
Close();
}
}
//查詢資料
//可以看看回傳結果集及取得資料方式
public void SelectTable()
{
try
{
stat = con.createStatement();
rs = stat.executeQuery(selectSQL);
System.out.println("ID\t\tName\t\tPASSWORD");
while(rs.next())
{
System.out.println(rs.getInt("id")+"\t\t"+
rs.getString("name")+"\t\t"+rs.getString("passwd"));
}
}
catch(SQLException e)
{
System.out.println("DropDB Exception :" + e.toString());
}
finally
{
Close();
}
}
//完整使用完資料庫後,記得要關閉所有Object
//否則在等待Timeout時,可能會有Connection poor的狀況
private void Close()
{
try
{
if(rs!=null)
{
rs.close();
rs = null;
}
if(stat!=null)
{
stat.close();
stat = null;
}
if(pst!=null)
{
pst.close();
pst = null;
}
}
catch(SQLException e)
{
System.out.println("Close Exception :" + e.toString());
}
}
public static void main(String[] args)
{
//測看看是否正常
jdbcmysql test = new jdbcmysql();
test.dropTable();
test.createTable();
test.insertTable("yku", "12356");
test.insertTable("yku2", "7890");
test.SelectTable();
}
4.15 期中考
package haha;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.DriverManager;
public class haha {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Hello! World!");
Connection c = null;
try {
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:test.db");
} catch (Exception e) {
System.err.println(e.getClass().getName() + ": " + e.getMessage());
System.exit(0);
}
System.out.println("Opened database successfully");
}
// TODO Auto-generated method stub
System.out.println("Hello! World!");
Connection c = null;
try {
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:test.db");
} catch (Exception e) {
System.err.println(e.getClass().getName() + ": " + e.getMessage());
System.exit(0);
}
System.out.println("Opened database successfully");
}
}
教學網站:
http://readandplay.pixnet.net/blog/post/140001110-%E7%AC%AC%E4%B8%80%E6%94%AFandroid-app%E7%A8%8B%E5%BC%8F%E6%95%99%E5%AD%B8
2016年2月18日 星期四
test1
參考:http://tccnchsu.blogspot.tw/
package teat;import java.sql.Connection;
import java.sql.DriverManager;
public class teat1 {
public static void main(String[] args) {
Connection c = null;
try {
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:test.db");
} catch (Exception e) {
System.err.println(e.getClass().getName() + ": " + e.getMessage());
System.exit(0);
}
System.out.println("Opened database successfully");
}
}
2015年11月19日 星期四
資料庫
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: 這行程式碼會將資料載入 '客戶dbDataSet.客戶' 資料表。您可以視需要進行移動或移除。
this.客戶TableAdapter.Fill(this.客戶dbDataSet.客戶);
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
}
}
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: 這行程式碼會將資料載入 '客戶dbDataSet.客戶' 資料表。您可以視需要進行移動或移除。
this.客戶TableAdapter.Fill(this.客戶dbDataSet.客戶);
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
}
}
2015年11月5日 星期四
簡易記算機
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 WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
float a = float.Parse(textBox1.Text), b = float.Parse(textBox2.Text);
label2.Text = (a + b).ToString();
}
private void button2_Click(object sender, EventArgs e)
{
float a = float.Parse(textBox1.Text), b = float.Parse(textBox2.Text);
label2.Text = (a - b).ToString();
}
private void button3_Click(object sender, EventArgs e)
{
float a = float.Parse(textBox1.Text), b = float.Parse(textBox2.Text);
label2.Text = (a * b).ToString();
}
private void button4_Click(object sender, EventArgs e)
{
float a = float.Parse(textBox1.Text), b = float.Parse(textBox2.Text);
if (b == 0)
{
label2.Text="分母為零";
}
else
{
label2.Text = (a / b).ToString();
}
}
}
}
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 WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
float a = float.Parse(textBox1.Text), b = float.Parse(textBox2.Text);
label2.Text = (a + b).ToString();
}
private void button2_Click(object sender, EventArgs e)
{
float a = float.Parse(textBox1.Text), b = float.Parse(textBox2.Text);
label2.Text = (a - b).ToString();
}
private void button3_Click(object sender, EventArgs e)
{
float a = float.Parse(textBox1.Text), b = float.Parse(textBox2.Text);
label2.Text = (a * b).ToString();
}
private void button4_Click(object sender, EventArgs e)
{
float a = float.Parse(textBox1.Text), b = float.Parse(textBox2.Text);
if (b == 0)
{
label2.Text="分母為零";
}
else
{
label2.Text = (a / b).ToString();
}
}
}
}
2015年10月30日 星期五
4*4 隨機亂數
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
{
public System.Windows.Forms.Button Button1;
Random rand = new Random();
Button[,] Buttons = new System.Windows.Forms.Button[5, 5];
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 1; i < 5; ++i)
{
for (int j = 1; j < 5; j++)
{
Buttons[i, j] = new Button();
Buttons[i, j].Size = new Size(50, 50);
Buttons[i, j].Location = new Point(i * 50, j * 50);
this.Controls.Add(Buttons[i, j]);//出現在畫面中
}
}
}
private void button1_Click(object sender, EventArgs e)
{
int x, y, a;
int[] myarray = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
for (int i = 15; i > 1; i--)
{
x = rand.Next(0, i);
y = myarray[x];
myarray[x] = myarray[i];
myarray[i] = y;
}
for (int j = 1; j < 5; j++)
{
for (int i = 1; i < 5; i++)
{
a = myarray[(j - 1) * 4 + (i - 1)];
Buttons[i, j].Text = Convert.ToString(a);
this.Controls.Add(Buttons[i, j]);
}
}
}
}
}
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
{
public System.Windows.Forms.Button Button1;
Random rand = new Random();
Button[,] Buttons = new System.Windows.Forms.Button[5, 5];
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 1; i < 5; ++i)
{
for (int j = 1; j < 5; j++)
{
Buttons[i, j] = new Button();
Buttons[i, j].Size = new Size(50, 50);
Buttons[i, j].Location = new Point(i * 50, j * 50);
this.Controls.Add(Buttons[i, j]);//出現在畫面中
}
}
}
private void button1_Click(object sender, EventArgs e)
{
int x, y, a;
int[] myarray = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
for (int i = 15; i > 1; i--)
{
x = rand.Next(0, i);
y = myarray[x];
myarray[x] = myarray[i];
myarray[i] = y;
}
for (int j = 1; j < 5; j++)
{
for (int i = 1; i < 5; i++)
{
a = myarray[(j - 1) * 4 + (i - 1)];
Buttons[i, j].Text = Convert.ToString(a);
this.Controls.Add(Buttons[i, j]);
}
}
}
}
}
2015年10月23日 星期五
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
int rndmoney1 = 100;
int rndmoney2 = 100;
int rndmoney3 = 100;
int rndmoney4 = 100;
int rndmoney5 = 100;
int rndmoney6 = 100;
int rndmoney7 = 100;
int rndmoney8 = 100;
int rndmoney9 = 100;
public Form1()
{
InitializeComponent();
}
private void button10_Click(object sender, EventArgs e)
{
Random rnd = new Random();
rndmoney1 = rnd.Next(0, 9);
rndmoney2 = rnd.Next(0, 9);
rndmoney3 = rnd.Next(0, 9);
//rndmoney4 = rnd.Next(0, 9);
//rndmoney5 = rnd.Next(0, 9);
//rndmoney6 = rnd.Next(0, 9);
//rndmoney7 = rnd.Next(0, 9);
//rndmoney8 = rnd.Next(0, 9);
//rndmoney9 = rnd.Next(0, 9);
button1.Text = rndmoney1.ToString();
button2.Text = rndmoney2.ToString();
if (rndmoney2 == rndmoney1)
{
MessageBox.Show("Dot Net Perls is awesome.");
rndmoney2 = rnd.Next(0, 9);
button2.Text = rndmoney2.ToString();
}
button3.Text = rndmoney3.ToString();
if (rndmoney1 == rndmoney3 || rndmoney2 == rndmoney3)
{
MessageBox.Show("Dot Net Perls is awesome.");
rndmoney3 = rnd.Next(0, 9);
button3.Text = rndmoney3.ToString();
}
//button4.Text = rndmoney4.ToString();
//button5.Text = rndmoney5.ToString();
//button6.Text = rndmoney6.ToString();
//button7.Text = rndmoney7.ToString();
//button8.Text = rndmoney8.ToString();
//button9.Text = rndmoney9.ToString();
}
}
}
{
public partial class Form1 : Form
{
int rndmoney1 = 100;
int rndmoney2 = 100;
int rndmoney3 = 100;
int rndmoney4 = 100;
int rndmoney5 = 100;
int rndmoney6 = 100;
int rndmoney7 = 100;
int rndmoney8 = 100;
int rndmoney9 = 100;
public Form1()
{
InitializeComponent();
}
private void button10_Click(object sender, EventArgs e)
{
Random rnd = new Random();
rndmoney1 = rnd.Next(0, 9);
rndmoney2 = rnd.Next(0, 9);
rndmoney3 = rnd.Next(0, 9);
//rndmoney4 = rnd.Next(0, 9);
//rndmoney5 = rnd.Next(0, 9);
//rndmoney6 = rnd.Next(0, 9);
//rndmoney7 = rnd.Next(0, 9);
//rndmoney8 = rnd.Next(0, 9);
//rndmoney9 = rnd.Next(0, 9);
button1.Text = rndmoney1.ToString();
button2.Text = rndmoney2.ToString();
if (rndmoney2 == rndmoney1)
{
MessageBox.Show("Dot Net Perls is awesome.");
rndmoney2 = rnd.Next(0, 9);
button2.Text = rndmoney2.ToString();
}
button3.Text = rndmoney3.ToString();
if (rndmoney1 == rndmoney3 || rndmoney2 == rndmoney3)
{
MessageBox.Show("Dot Net Perls is awesome.");
rndmoney3 = rnd.Next(0, 9);
button3.Text = rndmoney3.ToString();
}
//button4.Text = rndmoney4.ToString();
//button5.Text = rndmoney5.ToString();
//button6.Text = rndmoney6.ToString();
//button7.Text = rndmoney7.ToString();
//button8.Text = rndmoney8.ToString();
//button9.Text = rndmoney9.ToString();
}
}
}
2015年10月2日 星期五
程式設計工藝大師
應數物件導向C
應數物件導向C
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
int c = 0 ,d = 0 ;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
c = c + 1;
d = c % 3;
if( d == 1 )
{
button1.BackColor = System.Drawing.Color.Red;
button3.BackColor = System.Drawing.Color.Black;
button4.BackColor = System.Drawing.Color.Black;
}
else if (d == 2)
{
button1.BackColor = System.Drawing.Color.Black;
button3.BackColor = System.Drawing.Color.Yellow;
button4.BackColor = System.Drawing.Color.Black;
}
else if (d == 0)
{
button1.BackColor = System.Drawing.Color.Black;
button3.BackColor = System.Drawing.Color.Black;
button4.BackColor = System.Drawing.Color.Green;
button1.Text = c.ToString();
}
}
}
}
訂閱:
文章 (Atom)














