User Tools

Site Tools


click_boxes_lab

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
click_boxes_lab [2018/11/22 17:55] cthielclick_boxes_lab [2018/11/23 12:19] (current) cthiel
Line 1: Line 1:
-This Lab is a colorful way to practice the way to search and remove things in an ArrayList.+**Click Boxes Lab** 
 + 
 +{{ ::clickboxes.png?direct&400 |}} 
 + 
 +This Lab is a colorful way to practice how to search and remove things in an ArrayList. It is a perfect job for the while loop, because the size of the ArrayList is changing.  You may wish to re-read Chapter 11 section 5 (page 325) about this topic.
  
 You can see how it is supposed to work with this jar file: [[https://mathorama.com/apcs2/ClickBoxes.jar|ClickBoxes.jar]] You can see how it is supposed to work with this jar file: [[https://mathorama.com/apcs2/ClickBoxes.jar|ClickBoxes.jar]]
  
-{{ :box.java |Box.java}}+You will need the Box class which has some static Arrays and a static method about the color palette. {{ :box.java |Box.java}}
  
  
 +Your job is to complete the ''remove'' method of the ClickBoxes class.  You will need to to go through the ArrayList called ''boxes'' and look to see if it matches the color you care removing.  If it does, remove it from ''boxes'',  If it doesn't match, look for the next.  Here is the starter code:
 {{ ::clickboxes.java |ClickBoxes.java}} {{ ::clickboxes.java |ClickBoxes.java}}
 +==What else?==
 +  - In the ''Box'' class, add a String field called ''label''
 +  - In the ''Box'' class, add a ''setLabel'' method to have client classes change the contents of ''label'' 
 +  - In the ''Box'' class,  change the ''draw'' method so it draws the label.  The syntax of the graphics method that will do it is ''drawString( String s, int x, int y)''.  
 +  - In the ''ClickBoxes''' class alter the ''paintComponent'' method that changes the label of each box in the ''boxes'' ArrayList so that it it shows its order in the ArrayList.  
 +
  
click_boxes_lab.1542927313.txt.gz · Last modified: 2018/11/22 17:55 by cthiel

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki