******************************************************************************* 0) Administrative - hw: read Iterators webpage - A3 design assigned: handout, note differences from official version - big assignment, but a little design saves a LOT of coding (trust me!) - here's some info that you need Collection: a data structure (object or set of objects) that holds a list of items, so you don't have to keep track of them all individually - like a list of robots in an arena - you don't know how to write one yet, but one is written for you in A3 - you make a collection: TrashList trashList = new TrashList(); - then you add items to the collection: Trash t = new Trash(); trashList.add(t); // maybe params, maybe different names - then you tend to want to do something to every item in the collection - you get an iterator from the collection to give you one item at a time TrashListIterator itr = trashList.getIterator(); while (itr.hasMore()) { Trash t = iter.getNext(); // do something with t } KeyListeners: you can set up a graphics app to listen for key presses and call a specific method when a key gets pressed public void keyHit(char c) {} // has to be in your main class - gets called when user hits key, and key they hit gets passed in as c - you can choose what menu option to carry out by checking what c is Abstract classes and inheritance: - a class TrashObject that is "abstract" you can't make objects from - but you can make a subclass by saying Trash "extends TrashObject" - this forces Trash to implement some methods in TrashObject, which are needed in order for your classes to interact with the provided GUI - don't worry about details now; just use it 1) Last time- started loops, while and do-while 1) What's the value of x after these loops? int x=0, i=0; int x = 0; while (i < 6) { do { x += i; x -= 10; i += 2; } while (x > 0); } 2) What's wrong with these loops? int i=10, sum=0; do { while (i > 0) { takeTurn(); sum += i; boolean done = isGameOver(); i++; } while (!done); } 3) Write some code that corresponds to the following diagram: int i = 0; while (i<10) { if (i%2 == 0) { S.o.p("even"); } i++; } 2) Go over 6.4-6.7 in your groups 3) Highlights of material A. Another version: for loop - makes counting easier by putting everything in the header for (int i=0; i 0) { arena.add(new Robot(...)); x--; } - watch for posttest problems, and show for-header variations - which one is the best choice? (least repetition, easiest to get) B. Start planning the first program on the sheet - use a diagram, or an outline, or pseudocode 5) Summary - for loops, nesting loops *******************************************************************************