谁帮我讲解下这个java代码

谁帮我讲解下这个java代码,第1张

这个比较简单,没啥东西,就是每列开始行的选择,有点绕弯,我就注释下GraphicsPanel吧,主要的绘制工作都在这个类里面

    private class GraphicsPanel extends JPanel {

        public void paint(Graphics g) {

            Graphics2D g2d = (Graphics2D) g

            g2d. setFont (getFont (). deriveFont (Font. BOLD))

            g2d. setColor(Color. BLACK)

            g2d. fillRect (0, 0, screenSize. width, screenSize. height)   // 设置背景色为黑色

            

            int currentColumn = 0

            for (int x = 0 x < screenSize.width x += gap) {

                int endPos = posArr[currentColumn]      //获得开始行位置

                g2d. setColor(Color. GREEN)

                g2d.drawString(String.valueOf(getChr()), x, endPos * gap)     //画出随机开始行的字符

                

                int cg = 0                                                           //初始黑色

                for (int j = endPos -16 j < endPos j++) {           //随机行逐列向上16行,为循环开始行

                    cg += 15                                                     //渐变色15递增,255为green

                    if (cg > 255) {

                        cg = 255

                    }

                    g2d.setColor(new Color(0, cg, 0))

                    g2d.drawString(String.valueOf(getChr()), x, j * gap)    //画出随机行后的15行字符,颜色从黑色渐变成绿色,逐行增加

                }

                posArr[currentColumn] += random.nextInt(5)      //下落距离最快为4

                if (posArr[currentColumn] * gap > getHeight()) {  //如果行数位置大于屏幕高度,从新获取合适的行

                    posArr[currentColumn] = random.nextInt(lines)

                }

                currentColumn++    //下一列获取随机行

            }

import java.util.*/**规则在这里 http://www.zdic.net/appendix/f2.htm 超过字数了 我吧缩进删了*/public class SolarTerm {public static void main(String[] s) throws Exception{SolarTerm st = new SolarTerm()if(s.length == 3){System.out.println(st.getSoralTerm(Integer.parseInt(s[0]), Integer.parseInt(s[1]), Integer.parseInt(s[2])))}System.out.println(st.getSoralTerm(2009, 1, 5))System.out.println(st.getSoralTerm(2009, 1, 20))System.out.println(st.getSoralTerm(2009, 1, 23))System.out.println(st.getSoralTerm(2009, 2, 18))}final static long[] STermInfo = new long[] { 0, 21208, 42467, 63836, 85337,107014, 128867, 150921, 173149, 195551, 218072, 240693, 263343,285989, 308563, 331033, 353350, 375494, 397447, 419210, 440795,462224, 483532, 504758 }private static final String[] SolarTerm = new String[] { "小寒", "大寒", "立春", "雨水","惊蛰", "春分", "清明", "谷雨", "立夏", "小满", "芒种", "夏至", "小暑", "大暑", "立秋","处暑", "白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪", "冬至"}public SolarTerm(){}/** 核心方法 根据日期得到节气 */public String getSoralTerm(Date Date){Calendar cal = Calendar.getInstance()cal.setTime(Date)int y = cal.get(Calendar.YEAR)int m = cal.get(Calendar.MONTH) + 1int d = cal.get(Calendar.DAY_OF_MONTH)return getSoralTerm(y, m, d)}/** 核心方法 根据日期(y年m月d日)得到节气 */public String getSoralTerm(int y, int m, int d){String solarTermsif (d == sTerm(y, (m - 1) * 2)) solarTerms = SolarTerm[(m - 1) * 2]else if (d == sTerm(y, (m - 1) * 2 + 1)) solarTerms = SolarTerm[(m - 1) * 2 + 1]else{//到这里说明非节气时间 solarTerms = ""}return solarTerms}// ===== y年的第n个节气为几日(从0小寒起算)private int sTerm(int y, int n) {Calendar cal = Calendar.getInstance()cal.set(1900, 0, 6, 2, 5, 0)long temp = cal.getTime().getTime()cal.setTime(new Date( (long) ((31556925974.7 * (y - 1900) + STermInfo[n] * 60000L) + temp)))return cal.get(Calendar.DAY_OF_MONTH)}}

下雨指令:/weather rain,具体天气指令如下:

雨停的指令:/weather clear

雷雨指令: /weather thunder

晴天:/weather sun

雪天:/weather storm

输入指令

进游戏之后,什么命令秘籍输入过后都是没有权限,请问怎么获得这个权限,输入/op 名字也没有用,就连这个命令也没权限。按ESC键,点击“对局域网开放”然后把作“允许作弊”打开,然后按“创造一个局域网”,然后就可以输入了。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12101593.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-21
下一篇 2023-05-21

发表评论

登录后才能评论

评论列表(0条)

保存