Unformatted text preview:

CS112 - INTRODUCTION TO PROGRAMMINGProgramming Project #2 - Due Wednesday, March 2, at the start of classPurposes:1. To give you further experience with Java arithmetic and the use of the Math class.2. To give you further experience with drawing in Java using the methods of the Graphics class.IntroductionThis project is based on a variant of problems 5.21 and 5.22 in Wu. As you recall, problem 5.21 was the basis for Lab 5 in this course. What you will do for this project is to create a Java applet that - as a minimum - displays a nice clock and two input fields labelled “Hours” and “Minutes”. When the user enters a time into these fields and presses the “Enter” key on the keyboard, the clock will be set to the new time. Example:Your program must consist of a minimum of two classes: an applet class and a clock class. The latter will be based on the class you created in Lab 5, but with various improvements, as discussed below. You may enjoy looking at versions of a similar project created by students in previous years, linked off the course home page.After the projects are completed, your applet will be posted on the department’s web server so that fellow students, parents, friends, etc. can see what you’ve created as well.1EvaluationYour grade on this project will be based on three criteria:1. Correct, neat, and visually pleasing operation. (maximum 40-60 points, depending on options chosen)2. Good methodology, including documentation, use of comments, overall structure, choice of names, and good use of white space to aid readability (indentation and blank lines). (maximum 20 points)3. A project quiz, to be given on the due date. (maximum 20 points)A blank project cover sheet is attached and should be stapled to the front of your project submission.RequirementsMinimal requirements - up to 40 points for correct operationFulfill the requirements as stated above. Improve the appearance of the clock you created in Lab 5 in some or all of the following ways:• Add numbers and/or markers around the face of the clock• Improve the appearance of the clock hands. We’ll discuss possibilities for this in class.• Use color to make the clock more visually appealing.• Other creative possibilities of your own devisingCredit will be based on the aesthetics of the finished product. It is more beneficial to do what you do well than to do lots of things sloppily. Full credit will require doing all of the above, while demonstrating that you understand the formulas for positioning hands, markers etc. and that you have learned something beyond what we have explicitly covered in class or lab.Option 1 (Maximum of 5 additional points when added to the minimal requirements)Each clock should display the time both in digital form and in analog form. The digital time should be displayed before the label, just below the clock. Refer back to the discussion of formatting integers in class to be sure that times are correctly formatted - e.g. 1:03 should be displayed as 1:03, not 1:3 or 01:03. This must be handled by the clock object - not separately by the applet. (I.e. the clock object must display the digital time in its paint() method.) The following illustrates what this might look like:Option 2 (Maximum of 5 additional points when added to the minimal requirements - can be done with or without Option 1)Consider the task of drawing “hash marks” and time labels as in the example on page 1. This could be done by a series of statements like:graphics.drawString("1", calculated X position for 1:00 hour label, calculated Y position for 1:00 hour label);graphics.drawLine(calculated start X for 1:00, calculated start Y for 1:00,calculated finish X for 1:00, calculated finish Y for 1:00);2graphics.drawString("2", calculated X position for 2:00 hour label, calculated Y position for 2:00 hour label);graphics.drawLine(calculated start X for 2:00, calculated start Y for 2:00,calculated finish X for 2:00, calculated finish Y for 2:00);...graphics.drawString("12", calculated X position for 12:00 hour label, calculated Y position for 12:00 hour label);graphics.drawLine(calculated start X for 12:00, calculated start Y for 12:00,calculated finish X for 12:00, calculated finish Y for 12:00);It would be much nicer, however, if this were done using a for loop:for (int hour = 1; hour <= 12; hour ++){calculate position for hour label and hash marksgraphics.drawString(""+hour, calculated X position, calculated Y position);graphics.drawLine(calculated start X, calculated start Y,calculated finish X, calculated finish Y);}Where the positions for each hour label and hash mark are calculated based on the hour and the diameter of the clock. Implement both the drawing of 12 hash marks and 12 hour labels this way.(Hint: it is easy to calculate the position for the center of each label. It will take a bit of “tweaking” to get the label position to come out exactly right - especially the centering of the hour labels at 6:00 and 12:00, and the fact that the right hand side of the hour label is close to the clock for 7:00-11:00, while the left hand side of the hour label is close to the clock for 1:00-5:00. See the Hello class from Lab 5 for an example of how to center a label) The maximum of 5 points for this option will be given for hour labels and hash marks positioned perfectly symmetrically and elegant code.Option 3 (Maximum of 10 additional points when added to the minimal requirements - can be done with or without Options 1 and/or 2)North America encompasses a total of 8 time zones - listed here in order from east to west: Newfoundland, Atlantic, Eastern, Central, Mountain, Pacific, Alaska, and Hawaii. Information on converting times between these can be found at http://atm.geo.nsf.gov/ieis/time.html (all but Newfoundland) and http://www.education.gov.nf.ca/liv_rel_time.htm (Newfoundland Time). Modify your applet as follows:• Instead of displaying one clock, display eight clocks - each showing the time in a different time zone. The label below each clock should indicate its time zone. • One clock (Eastern Standard or the time zone of your home) should be displayed noticeably bigger than the other clocks (e.g. perhaps twice as big). The user will input the time in this zone, and the 8 clocks will each be set to the corresponding time in their zone. (Be sure your labelling of the input fields makes it clear to the user what zone the input is supposed to be in.).


View Full Document

Gordon CS 112 - PROJECT

Download PROJECT
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view PROJECT and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view PROJECT 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?