******************************************************************************* 0) Last time: introduced course, technical background, demo program, puzzles - anyone need info? 1) Administrative - corrections - questionnaire - hw: read chapter 1, bring book & ID to lab on Tues 2) Groups - organize and do intros - groups are for working together in class, and also for studying if you wish. - it's your responsibility to get each other the info if absent, and to explain things to each other if one doesn't understand. this should make things more fun, and help you all to do better in the class. - homeworks (after the first one) can have pairs collaborating, although you have to type and turn in your own versions. this can be good and I encourage it, as long as both partners understand everything that's going on (otherwise, it would put you at a severe disadvantage in the exams) 3) General principles - no online notes; sometimes examples, but it's really important to be here. - I don't always want to hear the right answers. I do want to hear them eventually, but first I want to hear the wrong answers, because then we have something to talk about. So if you're pretty sure you've got a wrong answer, speak up! - The best learners can make the worst teachers. Don't let anyone, especially me, get away with not understanding what you don't understand. And if you're struck with a brilliant explanation for something, please do volunteer it. 4) Building up a simple program (show last time's) - programs may take input, do calculations, and produce useful output - don't worry about the voodoo parts for now #1) initial program * comments, import, main class & method, braces, print, white space * useful to some extent, but only answers one tiny question (and author had to do the calculation instead of the program!) #2) modify: int x=5, print "x cubed is x*x*x" * identifiers, storing values, calculator math, concatenating * better, because now computer's doing the math * but still only answers one question- what about other numbers? #3) modify: x = getNumber(), uncomment method (voodoo) * methods, returning values * now it's beginning to look like a program * but not very user-friendly: not explanative, and text-based #4) replace whole body with promptNumber("Enter a number: ") * passing values, objects*, Java libraries * that's a pretty usable one * but there's one last step before it's actually good #5) Add comments * parts: types of comments, white space * a program can work perfectly and still be not-so-good *Objects - chunks of memory that store related data (in heap) - you can tell the computer to set aside a chunk for a particular kind - how does it know how much? for each kind, there's a file called a class - it's a blueprint for what gets stored in each instance - also in the class you can define methods that do stuff with that data - main class is simple- no data, one method- and can't instantiate - we'll see as part of A0 what an instantiable class looks like - JFrame class has been written already - create an object by writing type, then object name, then = new type() - then the chunk is ready to use - call its methods by writing name.methodName (sending a message) - looks like JFrame has data for size, location, visibility - JOptionPane is also a class, but we haven't made an object of it - sometimes you can use a method in a class without making an object first - it has to be a special kind of method 5) style guidelines - indentation and lining up of braces - line length - method length - file length - white space - comments - no professors' handwriting! 6) Software life cycle - analysis: determine requirements and specify features - design: create a detailed plan for the program (skipped for tiny ones, but very important later this term) - coding: write the program - testing: run it with many possible inputs to "debug" - operation/maintenance: use and update the program (should write programs that are easy to maintain-- well designed and clear to others) 7) Puzzles 1) One light coin in seven - Weigh three and three; if they balance, the other is it - Otherwise weigh one and one from the ligher three - If they match, the other is it; if not, the lighter is it 2) One question to find which way - "If I asked him which way heaven was, what would he say?" Suppose he replies "left". If he's lying, then the other would have said "right" and have been telling the truth. If he's telling the truth, then the other would have said "left" and be lying. Either way, the correct way to go is to the right-- the opposite of the answer. *******************************************************************************