Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write an applet to show the analog clock. The clock shape does not need to be a circle. It can be any shape as

Please write an applet to show the analog clock.

The clock shape does not need to be a circle. It can be any shape as long as it shows the time. However, it wont tell you the current time. Unlike the usual clock the arm for sec ticks on every 10 secs. So arm for minutes moves one click per 10 minutes and clock arm moves one click on every 10 hours.

For the sake of test make two buttons to start and stop the clock. You can consider the clock as a stop watch for the planet where the time passes 10 times slower than the time on earth.

Why we are doing this? Clock is one of the important components that OS relies on, further I want you to use and understand the sleep, suspend, wake, etc.

If your digital clock shows C sec,

Calculate secX(x coordinates for arm for sec and secY as follows;

secX = (int) (CPX + LM*(Math.sin(2*Math.PI*(C/60.0))));

secY = (int) (CPY - LM*(Math.cos(2*Math.PI*(C/60.0))));

where CPX means center of clock positions x coordinates,

CPY means center of clock positions y coordinates,

Then draw line from (CPX, CPY) to (sexX, sexy) as an arm for sec.

For example, if the clock is placed within the box (10, 60, 150, 150)

Meaning left top corner coordination is (10, 60),

With and length are 150 and the center coordination is (85, 135)

Then the secX amd secY can be calculated by

secX = (int) (85 + 70*(Math.sin(2*Math.PI*(secC/60.0))));

secY = (int) (135 -70*(Math.cos(2*Math.PI*(secC/60.0))));

the actual arm can be drawed by

drawline(85,135,secX,secY)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions