Announcements
|
||||||||||||||||
About Assignment A4, NaN, etc.. 1. NaN. In testing some of your methods,
you may get a message saying that the expected value was something
but the value produced was NaN. NaN is a constant of type double (just
as 1 is a constant of type int and true is
a constant of type boolean). It stands for Not a
Number. It is the value of an expression that divides by 0, among
other things. So it is quite likely that if you see such a method,
your program divided by 0. 4. Method toString(HSV hsv). This function should
truncate to 5 (five) characters, not 4. 2. Debugging. Some of you will find that the CMYK and HSV values that appear in your A4 GUI are not the same as the ones that appear in our solution. This means that you have to debug to find the errors. You are new to this game of debugging, and it can take time at the beginning. You are learning to solve problems, to act like a detective to find the mistakes. This debugging may take time. We give some pointers here. Note that you SHOULD check your GI against the solution GUI for number of different RGB values. The corresponding CMYK and HSV values should be the same as ours in both the original and the complementary colorpanes. Function toString. To debug, you have to see output. It would be nice to easily see a representation of CMYK and HSV colors. Unfortunately, classes HSV and CMYK do not have toString methods, so write them! We'll do one here. First, copy function truncate5 from class A4methods to class CMYK. Then, add this method to class CMYK: /** = string representation of this instance */ Remember to indent this nicely once it is pasted into the class. First step in testing. Suppose an RGB color that is giving the wrong CMYK value is (95, 109, 156). Then type this into the DrJava interactions pane, one line at a time. > rgb= new java.awt.Color(160, 146, 99); > res= A4Methods.RGB2CMYK(rgb); > res This will cause function res.toString to produce your corresponding CMYK value, and it will be printed. It will probably be wrong. This shows you how to begin looking at what the different functions do without using the GUI. Second step in testing. Nw put println statements in function RGB2CMYK to find out what values you are calculating. At the same time, use your little calculator (a hand-held one or one on your computer) to determine what values SHOULD be coming out, based on the formula given in the handout. For example, function CMYK probably may store a value in a variable Cprime. If so, put this statement in just after it is computed: System.out.println("CPRIME: " + Cprime); and then execute the above statements in the interactions pane again. This can be an arduous, painstaking process or an exciting period of time spent as a detective. It all depends on your attitude. But this kind of debugging HAS to be done in order to find the error. Avoiding the need to debug
About the CMS (Course
management system). We use a CS-designed "course management
system" to manage assignments, tests, etc. DON'T DO ANYTHING
ABOUT IT UNTIL WE ASK YOU TO! Thanks. The CMS for this course
is at this URL: http://cms3.csuglab.cornell.edu/. Fix your PCs so that extensions (like .java and .doc) ALWAYS appear. To
do this, do the following: Open an explorer window. Use menu item Tools
/ Click on Folder Options. Click the view tab. Uncheck the box "Hide extensions for known file types". Summaries of lectures Seeing consultants,
TAs, and Gries The TAs have office hours. If you need some conceptual help of any kind,
go the the TAs during their office hours. Choose any TA whose office
hours are convenient for you, you don't have to limit yourself to your
Section TA. Check here for office hours of TAs and the instructor. You can make an appointment for a one-on-one session with any TA at the undergrad office (Upson 303) between 9:30 and 4:30 M-F, or by emailing: ugrad@cs.cornell.edu--24 HOURS IN ADVANCE. Consultants for CS100 live in the ACCEL Lab, which you get to through
the Engineering Library in Carpenter Hall. You may spend a good
deal of time programming there. The consultants are there to answer
your questions. If you need help downloading and setting up DrJava,
if you have a misunderstanding on an assignment, if you are having
trouble debugging a program —in
all such matters, ask the consultants for a quick answer. However,
they will not write your program for you.
|
||||||||||||||||