zoukankan      html  css  js  c++  java
  • Java课程设计 猜数游戏个人博客

    1.团队课程设计博客链接

    http://www.cnblogs.com/tt1104/p/7064349.html

    2.个人负责模块或任务说明

    • 1.成绩排行榜算法的设计;
    • 2.排行榜存放到文件中,
    • 3.使用netbeans设计部分界面。

    3.自己的代码提交记录截图

    4.自己负责模块或任务详细说明

    设计排行榜,排行榜界面如下:

    主要代码如下:

    public static String readTxtFile(String txtPath, int lineNo) { 
    	   	String line = ""; 
            String encoding="GBK";
            try {
               File txtFile = new File(txtPath); 
               InputStream in = new FileInputStream(txtFile); 
               InputStreamReader read = new InputStreamReader(in,encoding); 
               BufferedReader reader = new BufferedReader(read); 
               int i = 0;
                while (i < lineNo) { 
                    line = reader.readLine(); 
                    i++;
                }
                reader.close(); 
            } catch (Exception e) {
            }
            return line;
    }
    
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            // TODO add your handling code here:
                String filePath = "D:\A\排行榜.txt";
                String s1=readTxtFile(filePath,1);
                jLabel2.setText(s1);
                 String s2=readTxtFile(filePath,2);
                jLabel5.setText(s2);
                 String s3=readTxtFile(filePath,3);
                jLabel6.setText(s3);
                 String s4=readTxtFile(filePath,4);
                jLabel7.setText(s4);
                 String s5=readTxtFile(filePath,5);
                jLabel8.setText(s5);
        } 
    

    将输出保存到文件中,截图如下:

    代码如下:

    File file = new File("D:\A");
        		file.mkdirs();
        		String path = "D:/A";
        		File f = new File(path);
        		if (!f.exists()) {
        			f.mkdirs();
        			String fileName = "排行榜.txt";// fileName1表示你创建的文件名;为txt类型;
        			File file1 = new File(f, fileName);
        			if (!file1.exists()) {
        				try {
        					file1.createNewFile();
        				} catch (IOException e) {
        					e.printStackTrace();
        				}
        			}
        		}
    

    5.课程设计感想

    • 感受:通过此次课程设计,不但对以往的知识更加熟悉,而且学到了很多新的东西,而且我们发现了很多不足的地方需要改进,希望能在以后的学习中,能更加的完善自我,是自己的代码更加简洁方便和人性化。

    • 建议:遇到不懂的知识点,需询问他人或自己上网查询,只要坚持,就一定可以完成任务。

  • 相关阅读:
    webpack 打包优化
    webpack 打包
    webpack 删除未使用函数
    Remote Address
    https://my.vmware.com/cn/group/vmware/evalcenter?p=vsphere-eval-7#tab_download
    python 代码检测
    windows 同时安装python2和python3并配置虚拟环境
    electron-log 修改日志保存路径
    png转ico源码
    Electron 开发点滴记录
  • 原文地址:https://www.cnblogs.com/zfy666/p/7066192.html
Copyright © 2011-2022 走看看