java源代码求一个java程序源码

java源代码  时间:2021-08-05  阅读:()

求一个简单java程序代码,谢谢

public class TestStar { public static void main(String[] args) { String star = "*"; for (int i = 0; i < 5; i++) { if (i == 0) { System.out.print(" " + star); System.out.println(); } if (i == 1) { for (int z = 0; z < 4; z++) { System.out.print(" " + star); } System.out.println(); } if (i == 2) { System.out.print(" "); for (int x = 0; x < 3; x++) { System.out.print(" " + star); } System.out.println(); } if (i == 3) { for (int y = 0; y < 2; y++) { System.out.print(" " + star + " "); } } } } } 是好使的 但是我没找到画五角星有什么规律(五角星好象不是正规图形吧?)如果还有什么要求的话 补充问题(如果是用*填充所有的东西 不包括 “ ”的话 我可以重新再给你写一个)

跪地求好玩的JAVA 源代码~

连连看java源代码 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;cols < 6;cols++){ for(int rows = 0;rows < 5;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;i < 6;i++){ for(int j = 0;j < 5;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==secondMsg && secondButton!=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;j<7;j++ ) { if (grid[x0][j]==0){ //判断第一个按钮同行哪个按钮为空 if (y>j) { //如果第二个按钮的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 (yx) { for (n=x0;n>=x+1 ;n-- ) { if (grid[n][j]!=0) { k=0; break; } if(grid[n][j]==0 && n==x+1) { remove(); } } } } } for (i=0;i<8;i++ ) { //列 if (grid[i][y0]==0) { if (x>i) { for (j=x-1;j>=i ;j-- ) { if (grid[j][y]!=0) { k=0; break; } else { k=1; } } if (k==1) { rowPassOne(); } } if (xy) { for (n=y0;n>=y+1 ;n--) { if (grid[i][n]!=0) { k=0; break; } if(grid[i][n]==0 && n==y+1) { remove(); } } } } } } } public void linePassOne(){ if (y0>j){ //第一按钮同行空按钮在左边 for (i=y0-1;i>=j ;i-- ){ //判断第一按钮同左侧空按钮之间有没按钮 if (grid[x0][i]!=0) { k=0; break; } else { k=2; } //K=2说明通过了第二次验证 } } if (y0i) { for (j=x0-1;j>=i ;j-- ) { if (grid[j][y0]!=0) { k=0; break; } else { k=2; } } } if (x0num) System.out.println("输入的数大了,输小点的!"); else if (shu求一个java程序源码

.jdom.*; .jdom.input.*; .jdom.output.*; import java.io.*; import java.util.List; /** * <p>Title: 使用JDOM解析XML</p> * <p>Description: 通过使用JDOM接口解析book.xml文件</p> * <p>Copyright: Copyright (c) 2003</p> * <p>Filename: JDOMParsePage.java</p> * @author 杜江 * @version 1.0 */ public class JDOMParsePage { /** *<br>方法说明:构造器,实现XML文件解析 *<br>输入参数: *<br>返回类型: */ public JDOMParsePage() { Document docJDOM; //利用SAX建立Document SAXBuilder bSAX = new SAXBuilder(false); try { //生成document对象 docJDOM = bSAX.build(new File("book.xml")); }catch (JDOMException e) { e.printStackTrace(); return; }

//得到Document的根(节点名:book) Element root = docJDOM.getRootElement(); System.out.println("根节点标记名:" + root.getName());

System.out.println("*****下面遍历XML元素*****"); //获得page元素集合 List list = root.getChildren("page"); //遍历page元素 for (int i=0; i < list.size() ; i++) { //获得page的元素 Element element = (Element)list.get(i); //获得ID属性 String id = element.getAttributeValue("id"); //获得title元素集合 List titleList = element.getChildren("title"); //获得title第一个元素 Element titleElement = (Element)titleList.get(0); //获得title元素的第一个值 String title = titleElement.getText(); //获得file元素集合 List fileList = element.getChildren("file"); //获得file第一个元素 Element fileElement = (Element)fileList.get(0); //获得file元素的第一个值 String file = fileElement.getText();

System.out.println("ID:" + id + " " + "标题:" + title + " " + "文件:" + file); } } /** *<br>方法说明:主方法,启动解析器 *<br>输入参数: *<br>返回类型: */ public static void main(String[] args) { JDOMParsePage myReader = new JDOMParsePage(); }

}

Boomer.host:$4.95/年-512MB/5GB/500GB/德克萨斯州(休斯顿)

部落曾经在去年分享过一次Boomer.host的信息,商家自述始于2018年,提供基于OpenVZ架构的VPS主机,配置不高价格较低。最近,主机商又在LET发了几款特价年付主机促销,最低每年仅4.95美元起,有独立IPv4+IPv6,开设在德克萨斯州休斯顿机房。下面列出几款VPS主机配置信息。CPU:1core内存:512MB硬盘:5G SSD流量:500GB/500Mbps架构:KVMIP/面板...

月神科技-美国CERA 5折半价倒计时,上新华中100G高防云59起!

官方网站:点击访问月神科技官网优惠码:美国优惠方案:CPU:E5-2696V2,机房:国人热衷的优质 CeraNetworks机房,优惠码:3wuZD43F 【过期时间:5.31,季付年付均可用】活动方案:1、美国机房:洛杉矶CN2-GIA,100%高性能核心:2核CPU内存:2GB硬盘:50GB流量:Unmilited端口:10Mbps架构:KVM折后价:15元/月、150元/年传送:购买链接洛...

raksmart:全新cloud云服务器系列测评,告诉你raksmart新产品效果好不好

2021年6月底,raksmart开发出来的新产品“cloud-云服务器”正式上线对外售卖,当前只有美国硅谷机房(或许以后会有其他数据中心加入)可供选择。或许你会问raksmart云服务器怎么样啊、raksm云服务器好不好、网络速度快不好之类的废话(不实测的话),本着主机测评趟雷、大家受益的原则,先开一个给大家测评一下!官方网站:https://www.raksmart.com云服务器的说明:底层...

java源代码为你推荐
codereviewios有什么好的代码review图像识别算法我想学习关于图像识别算法,但是讲到的数学知识我不太懂,希望大神们可以告诉我该怎么办。链接转换一个VB程序,简单的链接转换,怎么做?免费erp最方便使用的免费erp软件有哪些exe文件打不开我的电脑里面的EXE文件打不开啦html源代码求一个简单的HTML代码,在线等,急visio使用教程如何使用microsoft visio 2013mapsourcemapsource下载gps后的航点、航迹怎么转换成mapgis格式?邮件服务器软件给我推荐个邮件服务器软件?内详团购网源码最近看到团购挺火的,我也想做一个,请大家推荐个稳定的团购网站源码?
主机屋 日本软银 t牌 vpsio 商务主机 免费全能空间 毫秒英文 申请个人网站 200g硬盘 hkg 卡巴斯基试用版 中国电信测速网 空间技术网 hdd 腾讯总部在哪 1元域名 服务器论坛 杭州电信宽带优惠 supercache 乐视会员免费领取 更多