查看: 796|回复: 0
|
java problem
[复制链接]
|
|
import java.util.*;
class time
{
public static void main(String [] args)
{
int hour, min, sec;
Scanner sc = new Scanner(System.in);
System.out.print("Enter hours: ");
hour = sc.nextInt();
System.out.print("Enter minutes: ");
min = sc.nextInt();
System.out.print("Enter seconds: ");
sec = sc.nextInt();
// compute the canonical time and display
sec = (hour*3600)+(min*60)+sec;
hour = (sec/3600)%60;
min = ((sec*60)/3600)%60;
sec = (sec%60);
System.out.print(hour);
System.out.print( ":" );
System.out.print(min);
System.out.print( ":" );
System.out.print(sec);
World world = new World();
Turtle s = new Turtle(world);
Turtle t = new Turtle(world);
Turtle u = new Turtle(world);
int hourAngle,minAngle, secAngle;
// compute the three angle associated with the
// second-, minute-, and hour- hand
secAngle = sec*6;
minAngle = (min*60+sec)/10;
hourAngle = (hour*3600+min*60+sec)/120;
System.out.println();
System.out.print("Angle of the sec hand: ");
System.out.println(secAngle);
System.out.print("Angle of the minute hand: ");
System.out.println(minAngle);
System.out.print("Angle of the hour hand: ");
System.out.println(hourAngle);
// draw the clock face using Turtle t
t.right(hourAngle);
t.forward(100);
s.right(minAngle);
s.forward(120);
u.right(secAngle);
u.forward(160);
}
}
Using turtle graphics and dr java,how can i let d clock drawn by the turtle start clicking?i need to proceed from above.anyone can help?im desperately need sumone to enlighten me.thank you. |
|
|
|
|
|
|
| |
本周最热论坛帖子
|