Lab_05 - GCIS 501 Fall 2009 Lab 5 Summary You are to...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
GCIS 501 Fall 2009 Lab 5 Summary You are to develop a Java application that will ask the user for the time in terms of hour and minutes and display the time by drawing a clock (see the sample output on the last page). Designing a Solution To draw a clock and its attributes (face, hands, etc.) you will use another of Java’s built in classes: the Graphics class. To draw a clock hand, you use the drawLine() method of the Graphics class. The endpoints of the line are determined as: The value for the variable K determines the length of the clock hand. Make the K larger for the minute hand than for the hour hand. You may have to experiment a bit to get the proper value for K. The angle θ is expressed in radians. The angle θ min of the minute hand is computed as: (90.0 – Minute * 6.0) *( π /180.0) and the angle θ hr of the hour hand is computed as: (90.0 – (Hour + Minute/60.0) * 30.0) * ( π /180.0) where Hour and Minute are input values. The values 6.0 and 30.0 designate the degrees for one minute and one hour (i.e., the minute had moves 6 degrees in one minute and the hour had moves 30 degrees in one hour). The factor ( π /180.0) converts a degree value into the radian equivalent.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
You can draw the clock on a window by getting the window’s Graphic object. Make sure the window is visible on the screen before calling its getGraphic method. Your clock should resemble the sample output. It should be centered in your window and be approximately the same size. Make sure that you include the 12, 3, 6, and 9 o’clock numbers (more if you would like, but not less). You are to develop
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/17/2012 for the course GCIS 501 taught by Professor Liu during the Fall '09 term at Gannon.

Page1 / 5

Lab_05 - GCIS 501 Fall 2009 Lab 5 Summary You are to...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online