CSC152, Class 14: Laboratory on Java Basics Admin: * HW 14 due. * Note: If you know in advance you won't get a homework done, please tell me in advance. * Normal penalty: One letter grade. * HW 15 assigned: Conclude today's lab. Just email me that you're done. * Change in timing of exam 1: Assigned this Friday. * Goal of today's class: Resolve some of the problems you've been having. * Late: Sam's advisees (Eric, Eryn, and Michael). * Really late: Gaurav * No one expects to be able to do their chemistry lab in their dorm room, why do you expect to do your CS lab there? (But if you really find it better to work in your room, do so.) Overview: * Background stuff * Lab Background: * Two kinds of classes: Template classes and Main classes * Template classes provide templates for building new objects (e.g., Point) * Main classes provide a main method. (e.g., Main) * Classes fall within packages * Files must be in directories with the same name as the package. * Bring up the lab and try to do it. Question: * When Exercise 3 says "use package lab01.USERNAME", what are you going to do in preparation? * Open a new terminal window. * cd to CS152 * make a new directory called lab01 * share that directory * cd to that directory * make a new directory called USERNAME * share that directory * cd to that directory * You should use this model every time you do a homework! Observations and Comments: * Most of you have not memorized the imports and such. (That's fine) PrintWriter pen = new PrintWriter(System.out, true); * Having a sense of what you've done before and copy/paste is a good strategy. * Mastery varies wildly. At this point, 1a should be straightforward. if it's not, you need to assign yourself a few tasks like today's. * For comparing objects, such as strings, use the equals method, as in color.equals("blue") not color == "blue" * Remember: To execute a main class, use ji packagename.Class * No .java suffix * E.g., ji rebelsky.lab01a.Critic * Use the .java suffix primarily when compiling * Issues unrelated to the code you type can come into play * Whoops, I've been saving the file in the wrong directory. * Whoops, I was using a different name for this version of the class. * Java programming almost always involves creating multiple classes. You'll almost always need a main class to test your template classes.