CSC152 2004F, Class 15: More Fun in Lab Admin: * Extension on today's homework * New homework, too * Make sure to share those directories and files! Overview: * Q and A for yesterday's lab * New lab * Date interface * Implementation and test * Another implementation and test * Comments and thoughts /More notes on yesterday's lab and related issues/ * To move up a level in directories: cd .. * To move to your home directory, use no parameters cd * Share! * Your directories * Your files (share *.java) * To get the input on the same line as a prompt pen.print("Please enter your fave color: "); pen.flush(); // Yeah, mixed metaphors String fave = keyboard.readLine(); * To convert a string to a number String numstr = keyboard.readLine(); int num = Integer.parseInt(numstr); * An alternative int num; if (numstr.equals("1")) num = 1; else if (numstr.equals("2")) num = 2; else if (numstr.equals("3")) num = 3; else { pen.println("I'm lazy. I'm treating " + numstr + " as 4."); num = 4; } * Note: The directory structure for a package has to go *directly* below your CS152 directory. * Why? * The Java interpreter (ji) needs to find the package and the compiled code. If you say "lab01.rebelsky", it looks for a directory called lab01 and a directory called rebelsky within lab01. * If it's supposed to look "everywhere", it can take a long time. * If more than one of us uses the same package/directroy name (the horror!), how does it know which one to use? * The solution: The Java interpreter looks only in certain directories. export CLASSPATH=".:/home/rebelsky/Web/Courses/CS152/2004F/Examples/:/home/rebelsky/CS152" /Comments on Today's Lab/ * 30 days has September, April, June, and November. All the rest have 31, save February, which has 28 and doesn't rhyme. * While developing the DateV1 class, you may want to fill in STUBs for each method so that you can test each method in sequence. public Date tomorrow() { // STUB return new Date(this.dayofmonth, this.month, this.year); } // public int dayofyear() { return 0; // STUB } * The simplest constructor for DateV1 (and DateV2) takes three parameters: the day of the month, the month, and the year (all as integers). * Over-achievers might also want to support a constructor that accepts a string as a parameter. (Overkill) * Don't worry about DateV2 for the homework. * integers are exact, doubles are inexact. If you use only whole numbers, use integers. * Hi Michael B.