《JAVA语言》课程设计设计

2026/1/16 12:56:11

int hour = calendar.get(Calendar.HOUR); int minute = calendar.get(Calendar.MINUTE); int second = calendar.get(Calendar.SECOND); //draw the clock face

Ellipse2D clockFace = new Ellipse2D.Double(); clockFace.setFrameFromCenter(CENTER_X, CENTER_Y+RADIUS);

g2.setColor(Color.BLUE); g2.draw(clockFace); //draw the clock center

Ellipse2D clockCenter = new Ellipse2D.Double(); clockCenter.setFrameFromCenter(CENTER_X, CENTER_Y+INNER_RADIUS); g2.setColor(Color.RED); g2.fill(clockCenter);

//help to get the exact position of the lines double lenX, lenY, posX, posY; //draw the clock second line

Line2D clockSecond = new Line2D.Double();

double secondTime = (double) calendar.get(Calendar.SECOND); lenX = SECOND_LEN*Math.sin(2*Math.PI*secondTime/60.0); lenY = SECOND_LEN*Math.cos(2*Math.PI*secondTime/60.0); posX = CENTER_X + lenX; posY = CENTER_Y - lenY;

clockSecond.setLine(CENTER_X, CENTER_Y, posX, posY); g2.setColor(Color.PINK); g2.draw(clockSecond); //draw the clock minute line

Line2D clockMinute = new Line2D.Double();

CENTER_Y, CENTER_X+RADIUS,

CENTER_Y, CENTER_X+INNER_RADIUS,

double minuteTime = (double) calendar.get(Calendar.MINUTE);

lenX = MINUTE_LEN*Math.sin(2*Math.PI*(secondTime+60*minuteTime)/3600.0); lenY = MINUTE_LEN*Math.cos(2*Math.PI*(secondTime+60*minuteTime)/3600.0); posX = CENTER_X + lenX; posY = CENTER_Y - lenY;

clockMinute.setLine(CENTER_X, CENTER_Y, posX, posY); g2.setColor(Color.GREEN); g2.draw(clockMinute); //draw the clock hour line

Line2D clockHour = new Line2D.Double();

double hourTime = (double) calendar.get(Calendar.HOUR); lenX

=

HOUR_LEN*Math.sin(2*Math.PI*((secondTime+60*minuteTime+3600*hourTime)/43200.0)); lenY

=

HOUR_LEN*Math.cos(2*Math.PI*((secondTime+60*minuteTime+3600*hourTime)/43200.0)); posX = CENTER_X + lenX; posY = CENTER_Y - lenY;

clockHour.setLine(CENTER_X, CENTER_Y, posX, posY); g2.setColor(Color.BLUE); g2.draw(clockHour); int delay = 1000; // actionListener ActionListener drawClock; drawClock=new ActionListener(){

public void actionPerformed(ActionEvent evt){ repaint(); } };

//create timer

new Timer(delay, drawClock).start(); }

//variables of the panel private int HOUR_LEN = 50; private int MINUTE_LEN = 70; private int SECOND_LEN = 90; private int RADIUS = 100; private int INNER_RADIUS = 2; private int CENTER_X = 150; private int CENTER_Y = 150; }

2、 编程实现约瑟夫问题。8个人站成一圈,从第1个人开始报数,报到5的人出圈,第6个人

再从1开始报。依次类推,求出圈的序列。 public class Count5Quit{ public static void main(String args[]){ int a[] = new int[8]; for(int i=0;i

} } }

a[n] = -1; j = 0; ident++; } n++;

n = n % 8;

import java.awt.*; import java.awt.event.*; import javax.swing.*;

public class Els extends JFrame implements KeyListener,Runnable {

public Els() {

setSize(240,320); setUndecorated(true);

int H=(int) (this.getToolkit().getScreenSize().height);


《JAVA语言》课程设计设计.doc 将本文的Word文档下载到电脑
搜索更多关于: 《JAVA语言》课程设计设计 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219