南昌大学Java实验报告(1).doc

上传人:灯火****19 文档编号:135094229 上传时间:2020-06-12 格式:DOC 页数:17 大小:1.06MB
返回 下载 相关 举报
南昌大学Java实验报告(1).doc_第1页
第1页 / 共17页
南昌大学Java实验报告(1).doc_第2页
第2页 / 共17页
南昌大学Java实验报告(1).doc_第3页
第3页 / 共17页
南昌大学Java实验报告(1).doc_第4页
第4页 / 共17页
南昌大学Java实验报告(1).doc_第5页
第5页 / 共17页
点击查看更多>>
资源描述

《南昌大学Java实验报告(1).doc》由会员分享,可在线阅读,更多相关《南昌大学Java实验报告(1).doc(17页珍藏版)》请在金锄头文库上搜索。

1、 南昌大学实验报告学生姓名: 学 号: 专业班级: 实训类型: 验证 综合 设计 创新 实验日期:2017.11.1 实验成绩:一、 实验项目名称Java开发环境搭建和Java语言基础二、 实验的评分标准实验分为AF,A为最高,F最低。F:在规定时间内没有完成所有的实验,而且没有及时提交实验报告,或者实验过程中出现了抄袭复制他人实验代码。D:能完成实验,但是实验结果出现严重错误,不能体现对教学内容的理解。C:能基本完成实验,实验结果基本正确。但是实验内容有较少的错误,提交的实验代码质量一般。B:能较好的完成实验,实验报告条理清楚,实验代码结构清晰,代码质量较高,及时更正试验中出现的错误,并对运

2、行中一些异常错误进行分析,解释错误产生的原因。A:能较好的完成实验,实验代码质量高,实验报告完成度高,能在实验完成的基础上,根据个人的理解增加实验的新功能,具有一定的创新能力。三、 实验目的和要求1. 掌握Java的基础知识2. 掌握和运用Java的控制语句和数组3. 使用Eclipse平台开发Java应用四、 实验内容1. HelloWorld的应用程序和Applet程序。A. javap工具解析HelloWord字节码的类B.javap反汇编HelloWorld字节码C.修改代码,使之成为应用程序和Applet小程序两种程序的“入口”不同,一个是main()函数,一个是init()函数,所

3、以直接添加代码即可,运行时,根据IDE的run功能,选择相应的程序执行即可。 第一个和最后一个分别是Applet程序和Application程序 D.写文档注释,生成文件一些效果截图2. 打印日历程序 (长图)部分截图3. 枚举类统计Java成绩非法输入程序会报错退出正确结果自学了一下javafx,写了个简陋的UI。(要配合控制台输入数据,有待改进)4. 四连子游戏继续自学了一下javafx,给这个游戏包装了一个UI。本题和老师理解的要求可能有出入,游戏规则有点差别,但是底层逻辑是差不多的,于是我还是按照自己的想法写了下去,希望老师理解。 某一列下满,按钮失效获胜,信息提示绿色指示当前局该哪一

4、方落子平局Restart:清盘重玩Quit:退出实验源代码如下:-1.helloworld-package one;import java.applet.Applet;import java.awt.*;/* * This class is used to show hello world information * in two kinds of ways * * 1.print the information in the console * 2.generate an applet to display the info * * author Yuchen Tian */public c

5、lass HelloWorld extends Applet /* * main function for Application * param args */ public static void main(String args)/for application System.out.println(Hello World!); public void init() /for applet /* * create an graph on applet to show info * param g */ public void paint(Graphics g) g.drawString(

6、Hello World!,20,20); -2.printCalendar-Part1-package two;/*this Month enum defines the 12 months of all yearincluding the information of: index:the order in current class name:the full name of the month day:days in this month */public enum Month JAN(1,January,30),FEB(2,February,28),MAR(3,March,31),AP

7、R(4,April,30), MAY(5,May,31),JUN(6,June,30), JUL(7,July,31),AUG(8,August,31), SEP(9,September,30),OCT(10,October,31),NOV(11,November,30),DEC(12,December,31); private int index; private String name; private int day; Month(int index,String name,int day) this.index = index; this.name = name; this.day =

8、 day; public String getName() return name; public int getDay() return day; /when a month call this method,it becomes the month following it public Month next() int index = (this.index+1 12) ? 1 : this.index+1; return getMonthByIndex(index); /get a month according to the its index in the enum public

9、Month getMonthByIndex(int index) for(Month c:Month.values() if(c.index = index) return c; return null; -part2-package two;import java.util.Calendar;import java.util.GregorianCalendar;public class MyCalendar private int year; private int startDay; private Month m; public MyCalendar(int year) this.yea

10、r = year; this.startDay = getFirstDay(0,1) % 7;/month1,day1 m = Month.JAN; /start month of the year public int getFirstDay(int month, int day) GregorianCalendar tool = new GregorianCalendar(this.year,month,day); return tool.get(Calendar.DAY_OF_WEEK);/0 for Sun ,1 for Mon. public void printMonth(Mont

11、h m) /generate the head information of each month System.out.printf(%20sn,m.getName(); System.out.println(-); System.out.println(Su Mo Tu We Th Fr St); int count = 0; for(int i=0;istartDay;+i)/print blanks System.out.printf(%3c, ); count+; for(int i=1;i=getDays(m);+i)/print days System.out.printf(%2

12、d ,i); count+; if(count%7=0) System.out.println(); System.out.println(); startDay = (getDays(m) + startDay) % 7; /change the startDay for the next month public boolean isLeapYear() return year%400 = 0 | (year%4 = 0 & year%100 !=0); /get days in specific month /days in February is unique when it is leap year /hence,a special approach is implement to alter it right public int getDays(Month m) int days = m.getDay(); if(isLeapYear() & m.getName().equals(Month.FEB.getName()/special for February days += 1; return days; /once printed

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 总结/报告

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号