点点大阵java代码 点点大游戏

JAVA里如何获得指定大小字体的字符转成为点阵信息1、建一个内存DC 。
2、建一个CBitmap 。
3、把DC刷白 。
4、用TEXTOUT写字到DC上 。
5、用GetPixel()获得每个点
java算24点代码:输入4个数算24点,能够在命令提示符下就可以运行 。100多import java.util.Scanner;
/** 给定4个数字计算24 */
public class Core {
private double expressionResult = 24;
// private int maxLine=10;
private boolean error = true;
private double numbers[] = new double[4];
public Object resultReturn;
/**
* 该对象拥有3个私有变量 expressionResult,所需结果 maxLine,输出结果每页行数 error,是否出错
* numbers[4],记录用来运算的4个数
*
* 其次,该对象拥有以下方法供外部调用 setNumbers(double[] 运算的数) 输入用来运算的数,4个时才能计算,无返回
* setMaxLine(int 行数) 输入每页的行数,无返回 getMaxLine() 返回每页的行数,类型为int
* setExpressionResult(double 所需结果) 输入所需结果,无返回 getExpressionResult()
* 返回所需结果,类型为double getExpression() 返回可得出所需结果的表达式,类型为字符串数组
*
* 最后,私有方法均为计算与表达式转换部分
*/
// 测试使用
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int[] arr = new int[4];
System.out.print("输入第一个数:");
arr[0] = scanner.nextInt();
System.out.print("输入第二个数:");
arr[1] = scanner.nextInt();
System.out.print("输入第三个数:");
arr[2] = scanner.nextInt();
System.out.print("输入第四个数:");
arr[3] = scanner.nextInt();
Core s = new Core();
s.setNumbers(arr);
String[] output = s.getExpression();
for (int i = 0; ioutput.length; i) {
System.out.println(output[i]);
}
}
/** 设定被计算的四个数,由于是数组 , 所以具有容错功能(不为4个数) */
public void setNumbers(double[] n) {
if (n.length == 4) {
error = false;
numbers = n;
} else
error = true;
}
public void setNumbers(int[] n) {
if (n.length == 4) {
error = false;
for (int i = 0; i4; i) {
numbers[i] = n[i];
}
} else
error = true;
}
/** 设定每页显示的行数 */
// public void setMaxLine(int n) {
// if (n0) {
// maxLine=n;
// }
// }
// /** 返回每页显示的行数 */
// public int getMaxLine() {
// return maxLine;
// }
/** 设定需要得到的结果 */
public void setExpressionResult(double n) {
expressionResult = n;
}
/** 返回所需结果 */
public double expressionResult() {
return expressionResult;
}
/** 返回符合条件的表达式 */
public String[] getExpression() {
if (!error) {
String[] expression = calculate(numbers);
return expression;
} else
return new String[] { "出错了,输入有误" };
}
/** cal24() , 输出结果为24的表达式 */
private String[] calculate(double[] n) {
if (n.length != 4)
return new String[] { "Error" };
double[] n1 = new double[3];
double[] n2 = new double[2];
String[] resultString = new String[1024]; // 最多1000组解,暂时未溢出
int count = 0;
boolean isRepeat = false;
for (int t1 = 0; t16; t1) {
for (int c1 = 0; c16; c1) {
for (int t2 = 0; t23; t2) {
for (int c2 = 0; c26; c2) {
for (int c3 = 0; c36; c3) {
if ((c1 / 3 == c2 / 3(c1 % 3) * (c2 % 3) != 0)
|| (c2 / 3 == c3 / 3(c2 % 3) * (c3 % 3) != 0)
|| (c1 / 3 == c3 / 3
(c1 % 3) * (c3 % 3) != 0t2 == 2)) {
// 去除连减连除的解,因为x/(y/z)=x*z/y
continue;
}
n1 = cal1(n, t1, c1);
n2 = cal2(n1, t2, c2);
double result = cal(n2[0], n2[1], c3);
if ((result - expressionResult)0.00000001
(expressionResult - result)0.00000001) {
resultString[count] = calString(n, t1, c1, t2,
c2, c3)
"="(int) expressionResult;
for (int i = 0; icount; i) {
isRepeat = false;
if (resultString[i]
.equals(resultString[count])) { // 去除完全重复的解
isRepeat = true;
break; // 提前退出循环
}
}
if (c1 == c2c2 == c3c1 % 3 == 0
t1t2 != 0) { // 连加连乘
isRepeat = true;
}
if (!isRepeat) {
count;
}
}
}
}
}
}
}
if (count == 0)
return new String[] { "该组数无解" };
String[] resultReturn = new String[count];
System.arraycopy(resultString, 0, resultReturn, 0, count);
return resultReturn;
}
/** cal1(),将4个数计算一次后返回3个数 */
private double[] cal1(double[] n, int t, int c) { // t为原来的t1,c为原来的c1
double[] m = new double[3];
switch (t) {
case 0:
m[1] = n[2];
m[2] = n[3];
m[0] = cal(n[0], n[1], c);
break;
case 1:
m[1] = n[1];
m[2] = n[3];
m[0] = cal(n[0], n[2], c);
break;
case 2:
m[1] = n[1];
m[2] = n[2];
m[0] = cal(n[0], n[3], c);
break;
case 3:
m[1] = n[0];
m[2] = n[3];
m[0] = cal(n[1], n[2], c);
break;
case 4:
m[1] = n[0];
m[2] = n[2];
m[0] = cal(n[1], n[3], c);
break;
default:
m[1] = n[0];
m[2] = n[1];
m[0] = cal(n[2], n[3], c);
}
return m;
}
/** cal2(),将3个数计算一次后返回2个数 */
private double[] cal2(double[] n, int t, int c) { // t为原来的t2 , c为原来的c2
double[] m = new double[2];
switch (t) {
case 0:
m[1] = n[2];
m[0] = cal(n[0], n[1], c);
break;
case 1:
m[1] = n[1];
m[0] = cal(n[0], n[2], c);
break;
default:
m[1] = n[0];
m[0] = cal(n[1], n[2], c);
}
return m;
}
/** cal(),将2个数计算后返回结果 */
private double cal(double n1, double n2, int c) { // n1,n2为运算数,c为运算类型
switch (c) {
case 0:
return n1n2;
case 1:
return n1 - n2;
case 2:
return n2 - n1;
case 3:
return n1 * n2;
case 4:
if (n2 == 0)
return 9999; // 使计算结果必不为24
else
return n1 / n2;
default:
if (n1 == 0)
return 9999; // 同上
else
return n2 / n1;
}
}
/** calString(),输出表达式 */
private String calString(double[] n, int t1, int c1, int t2, int c2, int c3) {
String[] nString = new String[4];
switch (t1) {
case 0:
nString[0] = calString2(""(int) n[0], ""(int) n[1], c1);
nString[1] = ""(int) n[2];
nString[2] = ""(int) n[3];
break;
case 1:
nString[0] = calString2(""(int) n[0], ""(int) n[2], c1);
nString[1] = ""(int) n[1];
nString[2] = ""(int) n[3];
break;
case 2:
nString[0] = calString2(""(int) n[0], ""(int) n[3], c1);
nString[1] = ""(int) n[1];
nString[2] = ""(int) n[2];
break;
case 3:
nString[0] = calString2(""(int) n[1], ""(int) n[2], c1);
nString[1] = ""(int) n[0];
nString[2] = ""(int) n[3];
break;
case 4:
nString[0] = calString2(""(int) n[1], ""(int) n[3], c1);
nString[1] = ""(int) n[0];
nString[2] = ""(int) n[2];
break;
default:
nString[0] = calString2(""(int) n[2], ""(int) n[3], c1);
nString[1] = ""(int) n[0];
nString[2] = ""(int) n[1];
}
if ((c2 / 3c1 / 3(t2 != 2 || c2 / 3 == c3 / 3))
|| ((c3 / 3c1 / 3c2 / 3)t2 == 2)
|| (c3 == 1c1 / 3 == 0)) // 特定情况下加上一个括号*****************************
nString[0] = '('nString[0]')';
switch (t2) {
case 0:
nString[0] = calString2(nString[0], ""nString[1], c2);
nString[1] = nString[2];
break;
case 1:
nString[0] = calString2(nString[0], nString[2], c2);
break;
default:
nString[3] = nString[0];
nString[0] = calString2(nString[1], nString[2], c2);
nString[1] = nString[3];
}
if (c3 / 3c2 / 3 || (c3 == 2nString[0].indexOf(' ') = 0)) // 特定情况下加上一个括号*****************************
nString[0] = '('nString[0]')';
return calString2(nString[0], nString[1], c3);
}
/** calString(),根据符号输出一部运算表达式 */
private String calString2(String n1, String n2, int c) {
switch (c) {
case 0:
return n1' 'n2;
case 1:
return n1'-'n2;
case 2:
return n2'-'n1;
case 3:
return n1'*'n2;
case 4:
return n1'/'n2;
default:
return n2'/'n1;
}
}
}
java 源代码 基础点的谢谢package com.regex;
import java.io.*;
import java.net.URLDecoder;
import java.util.regex.*;
public class Regex {
private int REMARK=0;
private int LOGIC=0;
private int PHYSIC=0;
boolean start=false;
/**
* @param args
*/
public static void main(String[] args) { //测试方法
// TODO Auto-generated method stub
Regex re=new Regex();
re.regCount("Regex.java");
System.out.println("remark Line: " re.REMARK);
System.out.println("logic Line: " re.LOGIC);
System.out.println("physic Line: " re.PHYSIC);
}/**
* @author BlueDance
* @param s
* @deprecated count
*/
public void regCount(String s){
String url=null;
try {
【点点大阵java代码 点点大游戏】url=URLDecoder.decode(this.getClass().getResource(s).getPath(),"UTF-8");
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
try {
BufferedReader br=new BufferedReader(new FileReader(new File(url)));
String s1=null;
while((s1=br.readLine())!=null){
PHYSIC;
if(CheckChar(s1)==1){
REMARK;
System.out.println("纯注释行点点大阵java代码:" s1);
}
if(CheckChar(s1)==2){
LOGIC;
REMARK;
System.out.println("非纯注释行点点大阵java代码:" s1);
}
if(CheckChar(s1)==3)
LOGIC;
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}
}
/**
*
* @param s
* @return int
* @version check s
*/
public int CheckChar(String s){
String s1=null;
if(s!=null)
s1=s.trim();
//System.out.println(regCheck(s1,re));
if(regCheck(s1,"(//.*)"))//判断//开头的为纯注释行
return 1;
if(regCheck(s1,"(.*[;{})] *//.*)"))//判断不是//开头的非纯注释行
return 2;
if(regCheck(s1,"(//*.*)")){//判断/*开头的纯注释行
start=true;
return 1;
}
if(regCheck(s1,"(.*[;{})]//*.*)")){//判断不是/*开头的非纯注释行
start=true;
return 2;
}
if(regCheck(s1,"(.* */*/)")){//判断*/结尾的纯注释行
start=false;
return 1;
}
if(regCheck(s1,"(.* */*/.*)")!strCheck(s1)){ //判断不是*/结尾的非纯注释行
if(strCheck(s1)){
start=false;
return 2;
}
}
if(start==true)//状态代码,start即/*开始时start=true*/结束时为false
return 1;
return 3;//ssssllll
}//aeee
/**
*
* @param s
* @param re
* @return boolean
*/
public boolean regCheck(String s,String re){//正则表达试判断方法
return Pattern.matches(re,s);
}
public boolean strCheck(String s){//中间有*/的字符判断 此方法最关键
if(s.indexOf("*/")0){
int count=0;
String y[]=s.split("/*/");
boolean boo[]=new boolean[y.length];
for (int i = 0; iy.length-1; i) {
char c[]=y[i].toCharArray();
for (int j = 0; jc.length; j) {
if(c[j]=='\\'c[j 1]=='"'){
count;
}
}
if(count%2==0){
if(countNumber("\"",y[i])%2!=0){
boo[i]=true;
}else{
boo[i]=false;
}
}else{
if(countNumber("\"",y[i])%2==0){
boo[i]=true;
}else{
boo[i]=false;
}
}
}
for(int i=0;iboo.length;i){
if(!boo[i])
return false;
}
return true;
}
return false;
}
public int countNumber(String s,String y){//此方法为点点大阵java代码我前面写的字符串出现次数统计方法,不懂的可以看我前面的文章
int count=0;
String [] k=y.split(s);
if(y.lastIndexOf(s)==(y.length()-s.length()))
count=k.length;
else
count=k.length-1;
if(count==0)
System.out.println ("字符串\"" s "\"在字符串\"" y "\"没有出现过");
else
return count;
return -1;
}
}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class GoodLucky extends JFrame implements ActionListener{
JTextField tf = new JTextField(); //实例化一个文本域
//设置两个按钮
JButton b1 = new JButton("开始");
JButton b2 = new JButton("停止");
boolean isGo = false;
//构造函数
public GoodLucky(){
b1.setActionCommand("start");//在开始按钮上设置一个动作监听 start
JPanel p = new JPanel(); //实例化一个可视化容器
//将两个按钮添加到可视化容器上面 , 用add方法
p.add(b1);
p.add(b2);
//在两个按钮上增加监听的属性,自动调用下面的监听处理方法actionPerformed(ActionEvent e),如果要代码有更好的可读性,可用内部类实现动作
//监听处理 。
b1.addActionListener(this);
b2.addActionListener(this);
//将停止按钮设置为不可编辑(即不可按的状态)
b2.setEnabled(false);
this.getContentPane().add(tf,"North"); //将上面的文本域放在面板的北方,也就是上面(上北下南左西右东)
this.getContentPane().add(p,"South"); //将可视化容器pannel放在南边,也就是下面
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //设置用户在此窗体上发起 "close" 时默认执行的操作 , 参数EXIT_ON_CLOSE是使用 System exit 方法退出应用程序 。仅在应用程序中使用
this.setSize(300,200); //设置面板大小,宽和高
this.setLocation(300,300); //设置面板刚开始的出现的位置
Cursor cu = new Cursor(Cursor.HAND_CURSOR); //用指定名称创建一个新的定制光标对象,参数表示手状光标类型
this.setCursor(cu); //为指定的光标设置光标图像,即设置光标图像为上面所创建的手状光标类型
this.setVisible(true); //将面板可视化设置为true,即可视 , 如果为false,即程序运行时面板会隐藏
tf.setText("welcome you! "); //设置面板的标题为欢迎
this.go(); //调用go方法
}
public void go(){
while(true){ //这里是死循环 , 也就是说用户不点击停止按钮的话他一直循环出现随机数,直到用户点击停止按钮循环才能推出,具体流程在actionPerformed方法中控制 。
if(isGo == true){ //上面所定义的isGo的初始值为false,所以程序第一次到此会跳过
String s = ""; //设置空字符串
for(int j = 1; j = 7;j){ //产生7个随机数
int i = (int)(Math.random() * 36)1;//每个随机数产生方式,这里定义灵活,可以自由定义随机数产生的方式
if(i10){
s = s" 0"i; //如果产生的随机数小于10的话做处理:这里就牵扯到一个重要的概念,简单叙述一下:
/*
当一个字符串与一个整型数项相加的意思是连接 , 上面的s = s" 0"i的意思是字符串s链接0再连接整型i值,而不会导致0和整型的i相加,
产生的效果为s0i,由于s为空字符串(上面定义过的) , 所以当i小于零时,在个位数前面加上0,比如产生的随机数i为7的话,显示效果为 07.
*/
}else{
s = s" "i; //如果产生的随机数比10打的话,那么加上空格显示,即数字和数字之间有个空格
}
//以上循环循环七次 , 以保证能出现7个随机数
}
tf.setText(s); //将产生的随机数全部显示在文本域上,用文本域对象tf调用它的设置文本的方法setText(String)实现 。
}
//以下为线程延迟
try{
Thread.sleep(10); //线程类同步方法sleep,睡眠方法,括号里的单位为ms 。
}catch(java.lang.InterruptedException e){
e.printStackTrace(); //异常捕获,不用多说 。
}
}
}
//以下是上面设置的事件监听的具体处理办法,即监听时间处理方法,自动调用
public void actionPerformed(ActionEvent e){ //传入一个动作事件的参数e
String s = e.getActionCommand(); //设置字符串s来存储获得动作监听 , 上面的start
/*
以下这个条件语句块的作用为:用户点击开始后(捕获start,用方法getActionCommand()),将命令触发设置为true , 从而执行上面的go方法中的循环体(因为循环体中要求isGo参数为true,而初始为false) 。
执行循环快产生随机数,并将开始按钮不可编辑化,而用户只可以使用停止按钮去停止 。如果用户按下停止时,也就是没有传入参数“start”的时候,
执行else语句块中的语句,isGo设置为false,将不执行上面go中的循环语句块,从而停止产生随机数,并显示,并且把开始按钮设置为可用 , 而把
停止按钮设置为不可用 , 等待用户按下开始再去开始新一轮循环产生随机数 。
*/
if(s.equals("start")){ //如果捕获到start , 也就是用户触发了动作监听器 , 那么下面处理
isGo = true; //设置isGo为true
b1.setEnabled(false); //将开始按钮设置为不可用
b2.setEnabled(true); //将停止按钮设置为可用
}else{
isGo = false; //将isGo设置为false , isGo为循环标志位
b2.setEnabled(false); //设置停止按钮为不可用(注意看是b2,b2是停止按钮)
b1.setEnabled(true); //设置开始按钮为可用
}
}
public static void main(String[] args){
new GoodLucky(); //产生类的实例,执行方法
}
}
求一个简单的Java小游戏的代码连连看的小源码
package Lianliankan;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class lianliankan implements ActionListener
{
JFrame mainFrame; //主面板
Container thisContainer;
JPanel centerPanel,southPanel,northPanel; //子面板
JButton diamondsButton[][] = new JButton[6][5];//游戏按钮数组
JButton exitButton,resetButton,newlyButton; //退出,重列,重新开始按钮
JLabel fractionLable=new JLabel("0"); //分数标签
JButton firstButton,secondButton; //分别记录两次被选中的按钮
int grid[][] = new int[8][7];//储存游戏按钮位置
static boolean pressInformation=false; //判断是否有按钮被选中
int x0=0,y0=0,x=0,y=0,fristMsg=0,secondMsg=0,validateLV; //游戏按钮的位置坐标
int i,j,k,n;//消除方法控制
public void init(){
mainFrame=new JFrame("JKJ连连看");
thisContainer = mainFrame.getContentPane();
thisContainer.setLayout(new BorderLayout());
centerPanel=new JPanel();
southPanel=new JPanel();
northPanel=new JPanel();
thisContainer.add(centerPanel,"Center");
thisContainer.add(southPanel,"South");
thisContainer.add(northPanel,"North");
centerPanel.setLayout(new GridLayout(6,5));
for(int cols = 0;cols6;cols){
for(int rows = 0;rows5;rows){
diamondsButton[cols][rows]=new JButton(String.valueOf(grid[cols 1][rows 1]));
diamondsButton[cols][rows].addActionListener(this);
centerPanel.add(diamondsButton[cols][rows]);
}
}
exitButton=new JButton("退出");
exitButton.addActionListener(this);
resetButton=new JButton("重列");
resetButton.addActionListener(this);
newlyButton=new JButton("再来一局");
newlyButton.addActionListener(this);
southPanel.add(exitButton);
southPanel.add(resetButton);
southPanel.add(newlyButton);
fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable.getText())));
northPanel.add(fractionLable);
mainFrame.setBounds(280,100,500,450);
mainFrame.setVisible(true);
}
public void randomBuild() {
int randoms,cols,rows;
for(int twins=1;twins=15;twins) {
randoms=(int)(Math.random()*25 1);
for(int alike=1;alike=2;alike) {
cols=(int)(Math.random()*6 1);
rows=(int)(Math.random()*5 1);
while(grid[cols][rows]!=0) {
cols=(int)(Math.random()*6 1);
rows=(int)(Math.random()*5 1);
}
this.grid[cols][rows]=randoms;
}
}
}
public void fraction(){
fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable.getText()) 100));
}
public void reload() {
int save[] = new int[30];
int n=0,cols,rows;
int grid[][]= new int[8][7];
for(int i=0;i=6;i) {
for(int j=0;j=5;j) {
if(this.grid[i][j]!=0) {
save[n]=this.grid[i][j];
n;
}
}
}
n=n-1;
this.grid=grid;
while(n=0) {
cols=(int)(Math.random()*6 1);
rows=(int)(Math.random()*5 1);
while(grid[cols][rows]!=0) {
cols=(int)(Math.random()*6 1);
rows=(int)(Math.random()*5 1);
}
this.grid[cols][rows]=save[n];
n--;
}
mainFrame.setVisible(false);
pressInformation=false; //这里一定要将按钮点击信息归为初始
init();
for(int i = 0;i6;i){
for(int j = 0;j5;j){
if(grid[i 1][j 1]==0)
diamondsButton[i][j].setVisible(false);
}
}
}
public void estimateEven(int placeX,int placeY,JButton bz) {
if(pressInformation==false) {
x=placeX;
y=placeY;
secondMsg=grid[x][y];
secondButton=bz;
pressInformation=true;
}
else {
x0=x;
y0=y;
fristMsg=secondMsg;
firstButton=secondButton;
x=placeX;
y=placeY;
secondMsg=grid[x][y];
secondButton=bz;
if(fristMsg==secondMsgsecondButton!=firstButton){
xiao();
}
}
}
public void xiao() { //相同的情况下能不能消去 。仔细分析,不一条条注释
if((x0==x (y0==y 1||y0==y-1)) || ((x0==x 1||x0==x-1)(y0==y))){ //判断是否相邻
remove();
}
else{
for (j=0;j7;j) {
if (grid[x0][j]==0){ //判断第一个按钮同行哪个按钮为空
if (yj) { //如果第二个按钮的Y坐标大于空按钮的Y坐标说明第一按钮在第二按钮左边
for (i=y-1;i=j;i-- ){ //判断第二按钮左侧直到第一按钮中间有没有按钮
if (grid[x][i]!=0) {
k=0;
break;
}
else{ k=1; } //K=1说明通过了第一次验证
}
if (k==1) {
linePassOne();
}
}
if (yj){ //如果第二个按钮的Y坐标小于空按钮的Y坐标说明第一按钮在第二按钮右边
for (i=y 1;i=j ;i){ //判断第二按钮左侧直到第一按钮中间有没有按钮
if (grid[x][i]!=0){
k=0;
break;
}
else { k=1; }
}
if (k==1){
linePassOne();
}
}
if (y==j ) {
linePassOne();
}
}
if (k==2) {
if (x0==x) {
remove();
}
if (x0x) {
for (n=x0;n=x-1;n) {
if (grid[n][j]!=0) {
k=0;
break;
}
if(grid[n][j]==0n==x-1) {
remove();
}
}
}
if (x0x) {
for (n=x0;n=x 1 ;n-- ) {
if (grid[n][j]!=0) {
k=0;
break;
}
if(grid[n][j]==0n==x 1) {
remove();
}
}
}
}
}
for (i=0;i8;i) { //列
if (grid[i][y0]==0) {
if (xi) {
for (j=x-1;j=i ;j-- ) {
if (grid[j][y]!=0) {
k=0;
break;
}
else { k=1; }
}
if (k==1) {
rowPassOne();
}
}
if (xi) {
for (j=x 1;j=i;j) {
if (grid[j][y]!=0) {
k=0;
break;
}
else { k=1; }
}
if (k==1) {
rowPassOne();
}
}
if (x==i) {
rowPassOne();
}
}
if (k==2){
if (y0==y) {
remove();
}
if (y0y) {
for (n=y0;n=y-1 ;n) {
if (grid[i][n]!=0) {
k=0;
break;
}
if(grid[i][n]==0n==y-1) {
remove();
}
}
}
if (y0y) {
for (n=y0;n=y 1 ;n--) {
if (grid[i][n]!=0) {
k=0;
break;
}
if(grid[i][n]==0n==y 1) {
remove();
}
}
}
}
}
}
}
public void linePassOne(){
if (y0j){ //第一按钮同行空按钮在左边
for (i=y0-1;i=j ;i-- ){ //判断第一按钮同左侧空按钮之间有没按钮
if (grid[x0][i]!=0) {
k=0;
break;
}
else { k=2; } //K=2说明通过了第二次验证
}
}
if (y0j){ //第一按钮同行空按钮在与第二按钮之间
for (i=y0 1;i=j ;i){
if (grid[x0][i]!=0) {
k=0;
break;
}
else{ k=2; }
}
}
}
public void rowPassOne(){
if (x0i) {
for (j=x0-1;j=i ;j-- ) {
if (grid[j][y0]!=0) {
k=0;
break;
}
else { k=2; }
}
}
if (x0i) {
for (j=x0 1;j=i ;j) {
if (grid[j][y0]!=0) {
k=0;
break;
}
else { k=2; }
}
}
}
public void remove(){
firstButton.setVisible(false);
secondButton.setVisible(false);
fraction();
pressInformation=false;
k=0;
grid[x0][y0]=0;
grid[x][y]=0;
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==newlyButton){
int grid[][] = new int[8][7];
this.grid = grid;
randomBuild();
mainFrame.setVisible(false);
pressInformation=false;
init();
}
if(e.getSource()==exitButton)
System.exit(0);
if(e.getSource()==resetButton)
reload();
for(int cols = 0;cols6;cols){
for(int rows = 0;rows5;rows){
if(e.getSource()==diamondsButton[cols][rows])
estimateEven(cols 1,rows 1,diamondsButton[cols][rows]);
}
}
}
public static void main(String[] args) {
lianliankan llk = new lianliankan();
llk.randomBuild();
llk.init();
}
}
//old 998 lines
//new 318 lines
java小程序源代码,简单点的,100多行 , 谁有?。浚?/h2>// My car shop.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
public class carshop extends JFrame
{
// JPanel to hold all pictures
private JPanel windowJPanel;
private String[] cars = { "","阿斯顿马丁", "美洲虎", "凯迪拉克",
"罗孚", "劳斯莱斯","别克"};
private int[] jiage = { 0,150000, 260000, 230000,
140000, 290000, 150000};
// JLabels for first snack shown
private JLabel oneJLabel;
private JLabel oneIconJLabel;
// JLabels for second snack shown
private JLabel twoJLabel;
private JLabel twoIconJLabel;
// JLabels for third snack shown
private JLabel threeJLabel;
private JLabel threeIconJLabel;
// JLabels for fourth snack shown
private JLabel fourJLabel;
private JLabel fourIconJLabel;
// JLabels for fifth snack shown
private JLabel fiveJLabel;
private JLabel fiveIconJLabel;
// JLabels for sixth snack shown
private JLabel sixJLabel;
private JLabel sixIconJLabel;
// JTextField for displaying snack price
private JTextArea displayJTextArea;
// JLabel and JTextField for user input
private JLabel inputJLabel;
private JComboBox selectCountryJComboBox;
private JLabel inputJLabel2;
private JTextField inputJTextField2;
// JButton to enter user input
private JButton enterJButton;
//JButton to clear the components
private JButton clearJButton;
// no-argument constructor
public carshop()
{
createUserInterface();
}
// create and position GUI components; register event handlers
private void createUserInterface()
{
// get content pane for attaching GUI components
Container contentPane = getContentPane();
// enable explicit positioning of GUI components
contentPane.setLayout( null );
// set up windowJPanel
windowJPanel = new JPanel();
windowJPanel.setBounds( 10, 20, 340, 200 );
windowJPanel.setBorder( new LineBorder( Color.BLACK ) );
windowJPanel.setLayout( null );
contentPane.add( windowJPanel );
// set up oneIconJLabel
oneIconJLabel = new JLabel();
oneIconJLabel.setBounds( 10, 20, 100, 65 );
oneIconJLabel.setIcon( new ImageIcon( "images/阿斯顿马丁.jpg" ) );
windowJPanel.add( oneIconJLabel );
// set up oneJLabel
oneJLabel = new JLabel();
oneJLabel.setBounds( 10, 60, 100, 70 );
oneJLabel.setText( "阿斯顿马丁" );
oneJLabel.setHorizontalAlignment( JLabel.CENTER );
windowJPanel.add( oneJLabel );
// set up twoIconJLabel
twoIconJLabel = new JLabel();
twoIconJLabel.setBounds( 120, 20, 100, 65 );
twoIconJLabel.setIcon( new ImageIcon( "images/美洲虎.jpg" ) );
windowJPanel.add( twoIconJLabel );
// set up twoJLabel
twoJLabel = new JLabel();
twoJLabel.setBounds( 110, 60, 100, 70 );
twoJLabel.setText( "美洲虎" );
twoJLabel.setHorizontalAlignment( JLabel.CENTER );
windowJPanel.add( twoJLabel );
// set up threeIconJLabel
threeIconJLabel = new JLabel();
threeIconJLabel.setBounds( 230, 20, 100, 65 );
threeIconJLabel.setIcon( new ImageIcon(
"images/凯迪拉克.jpg" ) );
windowJPanel.add( threeIconJLabel );
// set up threeJLabel
threeJLabel = new JLabel();
threeJLabel.setBounds( 230, 60, 100, 70);
threeJLabel.setText( "凯迪拉克" );
threeJLabel.setHorizontalAlignment( JLabel.CENTER );
windowJPanel.add( threeJLabel );
// set up fourIconJLabel
fourIconJLabel = new JLabel();
fourIconJLabel.setBounds( 10, 100, 100, 65 );
fourIconJLabel.setIcon( new ImageIcon( "images/罗孚.jpg" ) );
windowJPanel.add( fourIconJLabel );
// set up fourJLabel
fourJLabel = new JLabel();
fourJLabel.setBounds( 10, 150, 50, 70 );
fourJLabel.setText( "罗孚" );
fourJLabel.setHorizontalAlignment( JLabel.CENTER );
windowJPanel.add( fourJLabel );
// set up fiveIconJLabel
fiveIconJLabel = new JLabel();
fiveIconJLabel.setBounds( 120, 100, 100, 65 );
fiveIconJLabel.setIcon( new ImageIcon(
"images/劳斯莱斯.jpg" ) );
windowJPanel.add( fiveIconJLabel );
// set up fiveJLabel
fiveJLabel = new JLabel();
fiveJLabel.setBounds( 110, 150, 100, 70 );
fiveJLabel.setText( "劳斯莱斯" );
fiveJLabel.setHorizontalAlignment( JLabel.CENTER );
windowJPanel.add( fiveJLabel );
// set up sixIconJLabel
sixIconJLabel = new JLabel();
sixIconJLabel.setBounds( 230, 100, 100, 65 );
sixIconJLabel.setIcon( new ImageIcon( "images/别克.jpg" ) );
windowJPanel.add( sixIconJLabel );
// set up sixJLabel
sixJLabel = new JLabel();
sixJLabel.setBounds( 230, 150, 100, 70 );
sixJLabel.setText( "别克" );
sixJLabel.setHorizontalAlignment( JLabel.CENTER );
windowJPanel.add( sixJLabel );
//set up enterJButton
enterJButton = new JButton();
enterJButton.setBounds( 390, 160, 135, 30 );
enterJButton.setText( "Enter" );
contentPane.add( enterJButton );
enterJButton.addActionListener(
new ActionListener() // anonymous inner class
{
// event handler called when enterJButton is clicked
public void actionPerformed( ActionEvent event )
{
enterJButtonActionPerformed( event );
}
} // end anonymous inner class
); // end call to addActionListener
//set up clearJButton
clearJButton = new JButton();
clearJButton.setBounds( 390, 200, 135, 30 );
clearJButton.setText( "Clear" );
contentPane.add( clearJButton );
// set up inputJLabel
inputJLabel = new JLabel();
inputJLabel.setBounds( 390, 25, 135, 25 );
inputJLabel.setText( "Please make selection:" );
contentPane.add( inputJLabel );
selectCountryJComboBox = new JComboBox( cars );
selectCountryJComboBox.setBounds( 390, 50, 135, 21 );
selectCountryJComboBox.setMaximumRowCount( 3 );
contentPane.add( selectCountryJComboBox );
// set up inputJTextField
inputJLabel2 = new JLabel();
inputJLabel2.setBounds( 390, 80, 150, 20 );
inputJLabel2.setText( "Input the Numble:" );
contentPane.add( inputJLabel2 );
// set up inputJTextField
inputJTextField2 = new JTextField();
inputJTextField2.setBounds( 390, 100, 135, 25 );
inputJTextField2.setHorizontalAlignment( JTextField.RIGHT );
contentPane.add( inputJTextField2 );
clearJButton.addActionListener(
new ActionListener() // anonymous inner class
{
// event handler called when clearJButton is clicked
public void actionPerformed( ActionEvent event )
{
clearJButtonActionPerformed( event );
}
} // end anonymous inner class
);
// set up displayJTextField
displayJTextArea = new JTextArea();
displayJTextArea.setBounds( 10, 237,515, 70 );
displayJTextArea.setEditable( false );
contentPane.add( displayJTextArea );
// set properties of application's window
setTitle( "My car Shop" ); // set title bar string
setSize( 550, 360 );// set window size
setVisible( true );// display window
} // end method createUserInterface
private void clearJButtonActionPerformed( ActionEvent event )
{
// clear the JTextFields
inputJTextField2.setText( "" );
displayJTextArea.setText("");
} // end method clearJButtonActionPerformed
private void enterJButtonActionPerformed( ActionEvent event )
{
double z;
double c;
int x;
int y;
x=selectCountryJComboBox.getSelectedIndex();
y=Integer.parseInt(inputJTextField2.getText());
double discountRate;
int amount = Integer.parseInt( inputJTextField2.getText());
switch (amount/5)
{
case 0:
discountRate = 0;
break;
case 1:
discountRate = 1;
break;
case 2:
discountRate = 2;
break;
case 3:
discountRate = 3;
break;
default:
discountRate = 4;
} // end switch statement
c=1-discountRate/100;
z=jiage[x]*y*c;
displayJTextArea.append("你选择点点大阵java代码的是点点大阵java代码:" cars[x] "点点大阵java代码;"
"它的单价是:" jiage[x] ";""你购买该产品的数量是:" y "点点大阵java代码,""\n" "该数量的折扣是:"
discountRate" %" ";" "本次消费的总价格是:" z "元" "!" "\n");
}
public static void main( String args[] )
{
carshop application = new carshop();
application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
} // end method main
} // end class carshop
点点大阵java代码的介绍就聊到这里吧,感谢你花时间阅读本站内容 , 更多关于点点大游戏、点点大阵java代码的信息别忘了在本站进行查找喔 。

    推荐阅读