Summer 12

Lecture Outlines


Final Exam Thursday 5-July

posted Jul 6, 2012, 9:49 AM by Rick M

Be there or take the final online

Lecture 17 Tuesday 3-July

posted Jul 3, 2012, 11:31 AM by Rick M   [ updated Jul 3, 2012, 2:37 PM ]

Announcements  

Homework

  • Finish Boggle 
  • OPTIONAL: email RandomWritingWithMap.java to Rick by 11:59 Wednesday  (5 pt bonus and a good practice test question concerning Maps
  • OPTIONAL: email BoggleGUI.java to Rick  by 11:59 Thursday  (5 pt bonus that may be completed after the final exam)

Lecture  

  • GUIsEventsCrashCourse.ppt   Follow along with the handout (print at home): FirstGuiHandout.pdf
  • In-Class assignment:
    • Implement an event-driven program with a graphical user interface (GUI) that pops up a dialog box to show how often the one button in the window is clicked.  See screenshot below for expected behavior (size and locate the JFrame to whatever you want).
break   ^ Part-1       Part 2 v
  • Note: Boggle needs a main method to run the console game, submit it to WebCat with the other files  15pts
    • If you already done this, email your Console game  Rick
  • 227FinalExamReviewSheetSummer12.pdf and consider the Practice Final Handout
  • Evals
  • Lab time to work on Boggle 
    • Should have at least an hour of lecture time
    • Rick, Lane or both of use will stay until 5:30 


Lecture 16 Monday 2-July

posted Jul 2, 2012, 11:36 AM by Rick M   [ updated Jul 3, 2012, 10:19 AM ]

Announcements  

  • Lecture begins at 1:15 pm today
  • Due Dates
    • OrderedSet<E extends Comparable<E>> new due date: Sunday 11:59 pm 
    • DiceTray still due Monday 11:59
    • Boggle still due Tuesday 11:59
    • OPTIONAL 5pt bonus RandomWriting Assignment Due Wednesday at 11:59 pm  (done during lecture or at home and emailed to Rick)
    • Should we do GUIs and Events on Tuesday for an optional 5 pt bonus to create a Boggle GUI?
  • Final Exam is Thursday, 1:00 pm in our usual lecture room (906 Gould Simpson)
    • 227PracticeFinalSummer12.pdf
      • Hard copies will be distributed Wednesday
    • Answers posted Tuesday afternoon under announcements for 3-July
    • Should we have a final exam review session, and if so when?
      • Maybe Wednesday 4th July 1:00 pm
  • GradesToOrderedSet.pdf (but not including OrderedSet)

Homework

  • Finish DiceTray and Boggle 
  • Work on RandomWritingWithMap.java (due in class or by Monday 1:12 pm)

Lecture  

  • Consider Boggle and a modified DiceTray class Boggle2Game.pdf
    • Search for QU should work even if there is no U in the DiceTray.  The Q is QU in Boggle
    • BoggleWords must be copied into the project, but not the folder src
    • We should be able to ask for the score at anytime and get the correct score
    • Several tests use the DiceTray with "ABSENTMINDENESS" found and user inputs in the spec
      • Consider using this to test Boggle in addition to other tests. 
    • If not using the WebCat Submission Plugin, make your main method one big comment with /* at the start and */ at the end
    • If working with a partner, put BOTH names on EVERY file
    • Any other questions?
  • HashTables.pdf slides 1..16 only
break      ^ Part-1          Part-2 v
    • RandomWriting with an ArrayList<Character> that stores every character that follows a piece of text (called an nGram)  
    Algorithm
    1) Read an entire book into a string
    2) Pick an initial 
    nGram randomly from that one big String that holds the entire book

    3) For each “random” char to print:
    • Make a new List<Character> to store every character in the book that follows the nGram
    • Randomly pick a character ch from that list
    • Print ch
    • Remove the 1st char from the nGram, append ch  
    Example 'book' and printing one character 
    Starting with the  nGram:  th” and this 'little' string:

    We hold these truths to be self-evident: that all men are created equal; that they

    Print one char 
    • build a new List<Character> [e, s, a, a, e]
    • pick character to print ch (random, could also be e or a): s
    • change nGram (remove first char, add printed char): hs

    • Rick creates the list of followers, ArrayList<Character> and runs the program to print 500 random characters
    • In-class Assignments (5 pt bonus). If at home, complete this and email the one file to Rick  (OPTIONAL)
      • Consider RandomWriting with a HashMap<String, ArrayList<Character>> that first creates a map of all possible nGrams (piece of text as the key in a Map) where the value is a list of every single letter that follows each   See RandomWriting 
    • Go to lab and work on DiceTray and/or Boggle

    Lecture 15 Thursday June 28

    posted Jun 28, 2012, 12:07 PM by Rick M   [ updated Jun 28, 2012, 3:00 PM ]

    Announcements  

    • OrderedSet<E extends Comparable<E>> due Friday night 11:59 pm (5 pt bonus for turning in 24 hours early)
    • MineSweeper and LinkedPriorityList turnins by the original due date now have a 5 pt bonus (any addition to previous assignments will be ignored)
    • Upcoming Lab hours in 930 Gould Simpson
      • Thu 10:30-12:55
      • Mon 10:30-1:12  (will be doing live grading of an Assignment) and 3:30-5:30
      • Tuesday 10:30-12:55 and 2:30-4:30
    • Lecture will begin at 1:15 pm next Monday in Gould-Simpson so Lane can check off an assignment in 930 GS (lab) or Rick in 906 GS (lecture)  (no WebCat for this one)
    • In case you were wondering, remaining Assignments (subject to adaption) 
      • 14. OrderedSet<E> 100pts  (assigned today, due Friday 11:59 pm)
      • 15. OPTIONAL Probabalistic Text Generation with java.util.HashMap(K, V)  (5pt bonus).  Online students: You must watch Fridays Screencasts before beginning this. It will be assigned Thursday and due Monday before lecture, checked off in lab from 10:30 am to 1:12 pm (online students email RandomWritingWithMap.java to lsimons@email.arizona.edu before 1:12 pm Arizona time Note: Lecture starts 15 minutes late on Monday) 
      • 15. Boggle 1: 100pts  (assigned Thursday, Due Monday)
      • 16. Boggle 2: 100pts  (assigned Thursday, Due Tuesday)
      • 17. OPTIONAL Implement a HashTable (5pt bonus)
      • 18. OPTIONAL GUI for Boggle  (5pt bonus)

    Homework

    • Finish OrderedSet<E implements Comparable<E>>
    • Work on RandomWritingWithMap.java (due in class or by Monday 1:12 pm

    Lecture  

    • Add method boolean isFull() to return true if every node has two children or zero children. Return false if any node has only one child. An empty tree isFull.  (tests and answers were printed and handed out, the same file is attached below for online students
    • Add method union()to OrderedSet that returns a new OrderedSet object that has all elements of this set and all elements of other
    • Discuss the remove algorithm needed for the 12th OrderedSet  problem boolean remove(E element)
    break    ^ Part-1        Part-2 v
    • Consider the final project  
      • Team signups today if in lecture
        • Give Rick a piece of paper with your name if solo or two names if a team of two.
      • If you are online and would to work with a partner through the cell phone and email, you may.  Post your request to Piazza
    • JavaCollectionFrameWork.pdf
    • In-Class Assignment RandomWritingWithMap.java (OPTIONAL now a 5 point bonus)

    Lecture 14 Wednesday 27-June

    posted Jun 27, 2012, 12:41 PM by Rick M   [ updated Jun 28, 2012, 10:36 AM ]

    Announcements  

    • RecursionFun (10 methods to WebCat) due 11:59 tonight (deadline extended by 1 day)
    • New Assignment Linked: OrderedSet<E extends Comparable<E>>
    • Upcoming Lab hours in 930 Gould Simpson
      • Wed 3:30-5:30
      • Thu 10:30-12:55
      • Mon 10:30-1:12  (will be doing live grading of an Assignment) and 3:30-5:30
      • Tuesday 10:30-12:55 and 2:30-4:30
    • Lecture will begin at 1:15 pm next Monday in Gould-Simpson so Lane can check off an assignment in 930 GS (lab) or Rick in 906 GS (lecture)  (no WebCat for this one)
    • In case you were wondering, remaining Assignments (subject to adaption) 
      • 14. OrderedSet<E> 100pts  (assigned today, due Friday 11:59 pm)
      • 15. Probabalistic Text Generation with java.util.HashMap(K, V)  25 points.  Online students: You must watch Fridays Screencasts before beginning this. It will be assigned Thursday and due Monday before lecture, checked off in lab from 10:30 am to 1:12 pm (online students email RandomWritingWithMap.java to lsimons@email.arizona.edu before 1:12 pm Arizona time Note: Lecture starts 15 minutes late on Monday) 
      • 15. Boggle 1: 100pts  (assigned Thursday, Due Monday)
      • 16. Boggle 2: 100pts  (assigned Thursday, Due Tuesday)
      • 17 Implement a HashTable (25pts)
      • 18. Optional Bonus GUI for Boggle  (up to 20 pts bonus possible)

    Homework

    • Read Chapter 19: Binary Search Trees
    • Finish RecursionFun
    • Begin OrderedSet<E implements Comparable<E>>

    Lecture  

    • 19-BSTandMaps.pdf
    • Code demo OrderedMap<K extends Comparable<E>, V> 
      • V put(K key, V value) return null if key does not exist or the old value being replaced by value
    break    ^ Part-1        Part-2 v
    • Continue code demo of OrderedMap<K, V> 
      • get(K)
      • int size() that runs O(n)
    • Consider the new Assignment: OrderedSet<E extends Comparable<E>> (except the last two methods List<E>  thoseGreaterThan  and  boolean remove(E) which will be discussed Thursday)

    Lecture 13 Tuesday 26-June

    posted Jun 26, 2012, 1:01 PM by Rick M   [ updated Jun 26, 2012, 9:50 PM ]

    Announcements  

    • Arizona wins the National Championship in baseball
    • Minesweeper due at 11:59 pm Today  (deadline extended by 1 day)
    • Recursion JavaBats due 11:59 pm tonight (extended 11 hours)
    • RecursionFun (10 methods to WebCat) due 11:59 Wednesday (deadline extended by 1 day)
    • Lab hours this week in 930 Gould Simpson
      • Tue and Wed 3:30-5:30
      • Thu 10:30-12:55

    Homework

    • Work on current assignments.  If you got a low grade on minesweeper, we can still get it 
    • Read chapter 18: Binary Trees

    Lecture  

    • Introduce 18-BinaryTrees.pdf 
    • Code Demo: Begin a new type: ExpressionTree
      • Use private inner class TreeNode with one constructor
      • Add constructor that can only build trees with a prefix expression with one operator only (hard coded, not general)
      • Implement prefix () to return the prefix version of the expression
      • Implement infix() to return the infix version of the expression
    Break          ^ Part-1        Part-2 v
      • implement valueOf() to evaluate an expression tree
      • Use Game of 20 Questions as an example of a binary tree
    Go to lab to work on any assignment

    Lecture 12 Monday 25-June

    posted Jun 25, 2012, 12:15 PM by Rick M   [ updated Jun 25, 2012, 3:09 PM ]

    Announcements  

    • Arizona is one win away from a National Championship
      • Need to win Today or Tomorrow
    • Reminder: Minesweeper due at 11:59 pm Today
    • Recursion JavaBats due 12:55 pm Tomorrow
    • New assignment linked this morning
      • RecursionFun (10 methods to WebCat) due 11:59 Tuesday
    • Lab hours this week in 930 Gould Simpson
      • Monday 10:30-12:55 and 3:30-5:30
      • Tues and Wed 3:30-5:30
      • Thursday 10:30-12:55

    Homework

    • Finish MineSweeper (due Monday night)
    • Work on Recursion JavaBats (due Tuesday before lecture)
    • Work on RecursionFun (due Tuesday night)

    Lecture  

    • Finish17-SimpleRecursion.pdf
    • Recursion on String JavaBat problems: stringClean and strDist
    • Recursion with Arrays through code demos.  Note: The number of arguments is kept minimal, need private helper methods to pass additional arguments
      • int occurencessOf(int value, int[] nums)
      • int maxInArray(int[] nums)
      • int indexOf(String[] names)
    Break     ^ Part-1          Part-2 v

    Go to lab to work on Minesweeper, Recursion JavaBats and/or RecursionFun

    Lecture 11 Thursday 21-June

    posted Jun 21, 2012, 12:55 PM by Rick M   [ updated Jun 25, 2012, 10:17 AM ]

    Announcements  

    • To get rid of the big ugly red warning in WebCat, add this suppress warning annotation before the method that has the  warning (yellow underline) in Eclipse or use the yellow lightbulb to have Eclipse add this
      • @SupressWarnings("unchecked")
    • Reminder: LinkedPriorityList<E> is due at 12:55 pm Thursday 
    • Lab hours this week in 930 Gould Simpson
      • Thursday 10:30-12:55  (LinkedPriorityList<E> due) and 3:30-5:30
    • Lab Hours Monday 25-June: 10:30-12:55
    • New assignment for recursion JavaBats will be posted at 4:30 pm today

    Homework

    • Finish LinkedPriorityList<E> implements PriorityList<E>
    • Begin MineSweeper
    • Work on Recursion JavaBats

    Lecture  

    • Thank you for yesterday's experiment, linked structures are challenging at first, I hope it helped
      • Please feel free to use laptops during lecture ...
    • 16-StacksQueues.pdf
    • Code demo: Rick writes the first part of a compiler to check for balanced symbols. Here is an algorithm:
    1) Make an empty stack named s
    2) Read symbols until end of file 
         if it's an opening symbol, push it
         if it is a closing symbol && s.empty
              report error
         otherwise
              pop the stack
         if symbol is not a closer for pop's value, report error
    3. At end of file, if !s.empty, report error

    Break       ^ Part-1             Part-2 v
      Break       ^ Part-2             Part-3 v

      Lecture 10 Wednesday 20-June

      posted Jun 20, 2012, 12:54 PM by Rick M   [ updated Jun 21, 2012, 8:49 AM ]

      Announcements  

      • To get rid of the big ugly red warning in WebCat, add this before the method that is a yellow warning in Eclipse (or use the yellow lightbulb to have Eclipse add it):
        • @SupressWarnings("unchecked")
      • Reminder: LinkedPriorityList<E> is due at 12:55 pm Thursday 
        • It was WebCatted at 10:00 am this morning
      • Lab hours this week in 930 Gould Simpson
        • Wed ~3:30-5:30
        • Thursday 10:30-12:45  (LinkedPriorityList<E> due)

      Homework

      • If you haven't done so already and you haven't completed LinkedPriorityList<E>, read Chapter 15: "The Singly-linked Structure" and answer all self-checks
      • Finish LinkedPriorityList<E> implements PriorityList<E> tonight or tomorrow morning (different times in China)

      Lecture 

      • Iterable objects
        • No laptops during lecture today please
        • Rick adds an inner class so we can iterate over ArrayBag<E> elements with hasNext() and next()
        • In teams of two or three (or solo if you want)
        • 1) Make GenericBag Iterable (need to add an inner class so we can iterate over LinkedBag<E> element with hasNext() and next()
        • 2) Change the add method to add at the end (currently adds at front in one line of code) 
      Break       ^ Part-1             Part-2 v
      • An OrderedList<E> type
        • Rick does insertInOrder(E element) and boolean isSorted()
        • In teams of two or three (or solo if you want) complete removeAll(E el)  CANCELLED

      Go to lab to work on LinkedPriorityList<E> if necessary

      Lecture 9 Tuesday 19-June

      posted Jun 19, 2012, 12:33 PM by Rick M   [ updated Jun 19, 2012, 6:50 PM ]

      Announcements  

      • There are many details in ArrayPriorityList that can trip you up.  A few are given at the beginning of the lecture outline below
      • Reminder: ArrayPriorityList is due at 5:30 pm Tuesday
      • Lab hours this week in 930 Gould Simpson
        • Tuesday and Wed ~3:30-5:30
        • Thursday 10:30-12:45  (LinkedPriorityList<E> due.
      • Test Statistics
        • Median:  177 or 88.5
        • Average: 170 or 85%
        • Max: 196 or 98%
        • Min: 95 or 47.5%

      Homework

      • Read Chapter 15: The singly-linked structure
        • answer all self-checks
      • Begin LinkedPriorityList<E> implements PriorityList<E> 

      Lecture  We will have 4 screencasts today (parts 1, 2, 3, and 4)


      Part-1: Hand back tests, go over answers/criteria  (short video), show link to all grades so far by CSID 


               BREAK

      Part-3: Code Demo
      • Implement bag with a singly-linked structure
        • Need an inner class
      • Make it so we can iterate over it with implements Iterable<E>
        • Need an inner class again
      • Consider LinkedPriorityList<E>, spec and pictures
      Part-4: Questions on ArrayPriorityList<E>  spec  (Part-1, a short video for those who have not finished ArrayPriorityList<E> for 100%)
      • 1) Do I need a Movie class?  Yes and MovieTest for its unit test to get 100%
      • 2) Do I have to grow my array?  Yes.  Begin with a capacity like 20 and add 22 elements, check element at index 20 and 21
      • 3) Do I have to test to ensure my methods throw exceptions?  Yes, every method that claims to throw an exception should
        • Hint: It is easy to be off by one
      • 4) How do I test to make sure my method has thrown an exception at the correct time? See spec and/or Chapter 13
        • Note: Do not have any assertion after the assertion that is supposed to throw the exception.  JUNit skips remaining assertions and you lose WebCat code coverage points
      • 5) How do you test toArray()?
        • Object[] clone = list.toArray();
        • clone[0] should be a reference to the same object as list.getElementAt(0)
        • clone[0] = new Movie("Ali", 4); should NOT change return oflist.getElementAt(0);
        • in toArray(), do not return a reference to your Object[] instance variable!
        • Make a new array, copy elements, and return reference to this new array
        • Could be 0 elements, then  return new Object[0];
      • 6)  How many files do we need in our one Eclipse project?
        • PriorityList<E>   (the ADT)
        • ArrayPriorityList<E>   (the collection class)
        • ArrayPriorityListTest (a unit test needed to get 100% code coverage and not a 0)
        • Movie  (a simple little class need to run the GUI, without it you get 0/100 due to WebCat not finding call Movie--compile time error)
        • MovieTest (a unit test needed to get 100% code coverage)
        • Optional PriorityListGUI (use this to see your work in action)
      • 7) Can I use the same tests form ArrayPriorityList<E> in the next project LinkedPriorityList<E>?  Yes, simply change Array to Linked
      • 8) Any other questions?
      Go to lab to finish ArrayPriorityList<E> or begin LinkedPriorityList<E>

      1-10 of 19