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(); }

}

速云:深圳独立服务器,新品上线,深港mpls免费体验,多重活动!

速云怎么样?速云是一家国人商家。速云商家主要提供广州移动、深圳移动、广州茂名联通、香港HKT等VDS和独立服务器。目前,速云推出深圳独服优惠活动,机房为深圳移动机房,购买深圳服务器可享受5折优惠,目前独立服务器还支持申请免费试用,需要提交工单开通免费体验试用,次月可享受永久8折优惠,也是需工单申请哦!点击进入:速云官方网站地址活动期限至 2021年7月22日速云云服务器优惠活动:活动1:新购首月可...

JustHost:俄罗斯/新西伯利亚vps,512MB内存/5GB空间/不限流量/200Mbps/KVM/自由更换IP,$1.57/月

justhost怎么样?justhost是一家俄罗斯主机商,2006年成立,提供各种主机服务,vps基于kvm,有HDD和SSD硬盘两种,特色是200Mbps不限流量(之前是100Mbps,现在升级为200Mbps)。下面是HDD硬盘的KVM VPS,性价比最高,此外还有SSD硬盘的KVM VPS,价格略高。支持Paypal付款。国内建议选择新西伯利亚或者莫斯科DataLine。支持Paypal付...

弘速云20.8元/月 ,香港云服务器 2核 1g 10M

弘速云元旦活动本公司所销售的弹性云服务器、虚拟专用服务器(VPS)、虚拟主机等涉及网站接入服务的云产品由具备相关资质的第三方合作服务商提供官方网站:https://www.hosuyun.com公司名:弘速科技有限公司香港沙田直营机房采用CTGNET高速回国线路弹性款8折起优惠码:hosu1-1 测试ip:69.165.77.50​地区CPU内存硬盘带宽价格购买地址香港沙田2-8核1-16G20-...

java源代码为你推荐
app退款app退款怎样才算恶意退款?aftereffectAfter effect Premere分别是什么软件,做什么的?订单详情淘宝购物记录具体指什么?是订单详情还是交易聊天记录???讯飞tts能配合讯飞语音tts使用的手机阅读器都有哪些好用的手机杀毒软件好用的手机杀毒软件dreamweaver序列号DW序列号是多少啊spinmaster技术滑板截图方法无线呼叫系统什么是无线呼叫器?3d规则3d中奖规则刷荣誉怎么刷荣誉啊
主机租用 域名升级访问 主机屋 免费申请网页 韩国俄罗斯 私人服务器 128m内存 美国仿牌空间 空间打开慢 ibox官网 秒杀预告 广州服务器 免费私人服务器 外贸空间 秒杀品 东莞主机托管 ledlamp 镇江高防 酸酸乳 xuni 更多