1 / 19

Announcements & Review

Course on-line survey due Tuesday 10pm on eBlackboard Exam Wednesday 12/7 ACES 2.302 5:30--7:30 Tournament cancelled Discussion section grades drop first 5 or average out. Topics to review: background for, while, if/else, … read from file array of objects

maxine
Download Presentation

Announcements & Review

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Course on-line survey due Tuesday 10pm on eBlackboard Exam Wednesday 12/7 ACES 2.302 5:30--7:30 Tournament cancelled Discussion section grades drop first 5 or average out Topics to review: background for, while, if/else, … read from file array of objects two dimensional arrays Color sorting bubble, quick, merge recursion GUI Announcements & Review

  2. Basic Exam Format Open book, open notes - No computers or cell phones - I suggest you print out your programming assignment solutions and/or my in class examples 5 questions: • 4 short answer, similar to previous exam • object allocation • I/O and efficient representation & computation • Image manipulation • Class design

  3. Topics you understand • for loops • while loops • I/O • conditionals • classes, objects, methods, instance variables • arrays -------------------------------------------------------- • File input • Image manipulation • Sorting • Recursion • GUI

  4. File Input • use Scanner class • same methods used with terminal • nextInt() • next() • hasNextInt()

  5. Image Manipulation • int[][] myPixels • height = myPixels.length • width = myPixels[0].length • int -> Color • myColor = new Color(myPixels[i][j]); • Color -> int • myPixels[i][j] = myColor.getRGB(); • Color manipulation • Color black = new Color(0,0,0); • int red = myColor.getRed(); • getGreen(), getBlue()

  6. Sorting - BubbleSort • one element at a time • moving 7+6+5+4+3+2 = 27 times

  7. Sorting - MergeSort • divide by half and sort each half • moving (1+1+1+1) + (2+2) + (4) = 12 times

  8. Sorting - QuickSort • left < pivot < right • moving 7+ (3+2) + 1 = 13 times

  9. BubbleSort Algorithm for (int i=0; i<array.length; i++) { for (int j=0; j<array.length-i ; j++) { if (array[i]>array[j]) { swap array[i] and array[j]; } } }

  10. MergeSort Algorithm MergeSort(array) { MergeSort(first half); MergeSort(second half); Merge first and second; }

  11. QuickSort Algorithm QuickSort(array) { choose pivot; partition array; //small to left, big to right QuickSort(left); QuickSort(right); }

  12. Recursion • Repetition with a smaller problem size • organism marking • merge sort, quick sort • tower of hanoi • How to use • Call the method in itself, with different parameter

  13. Remember where PC was hanoi(3, src, aux, dst) hanoi(2, src, dst, aux) hanoi(2, aux, src, dst) hanoi(2, src, dst, aux) hanoi(1, src, aux, dst) hanoi(1, aux, dst, src) hanoi(2, aux, src, dst) hanoi(1, dst, src, aux) hanoi(1, src, aux, dst) • First-In Last-Out

  14. Recursion as Stack • First-In Last-Out

  15. Graphical User Interface • Components, Containers, Layouts • Components • an object having a graphical representation that can be displayed on the screen and that can interact with the user. • e.g. Canvas, JButton, JLabel, JRadioButton, JTextField, JSlider,

  16. Container • Container • public class Container extends Component • A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT components. • Components added to a container are tracked in a list. • e.g. JFrame, JPanel

  17. LayoutManager • public interface LayoutManager • Defines the interface for classes that know how to lay out Containers. • e.g. BorderLayout, FlowLayout, GridLayout

  18. Big Picture Container(JPanel) Container(JPanel) Container(JPanel) Container(JFrame) LayoutManager Components Components Components

  19. Thank you!

More Related