Announcements - PowerPoint PPT Presentation

About This Presentation
Title:

Announcements

Description:

Announcements & Review. Course on-line survey due Tuesday ... Tournament cancelled. Discussion section grades. drop first 5 or. average out. Topics to review: ... – PowerPoint PPT presentation

Number of Views:19
Avg rating:3.0/5.0
Slides: 20
Provided by: CSCF
Category:

less

Transcript and Presenter's Notes

Title: Announcements


1
Announcements Review
  • Course on-line survey due Tuesday 10pm on
    eBlackboard
  • Exam Wednesday 12/7
  • ACES 2.302
  • 530--730
  • 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

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 myPixels0.length
  • int -gt Color
  • myColor new Color(myPixelsij)
  • Color -gt int
  • myPixelsij 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 765432 27 times

8 7 6 5 4 3 2 1
7 8 6 5 4 3 2 1
7 6 8 5 4 3 2 1
7 6 5 8 4 3 2 1
7 6 5 4 8 3 2 1
7 6 5 4 3 8 2 1
7 6 5 4 3 2 8 1
7 6 5 4 3 2 1 8
7
Sorting - MergeSort
  • divide by half and sort each half
  • moving (1111) (22) (4) 12 times

8 7 6 5 4 3 2 1
8 7 6 5 4 3 2 1
8 7 6 5 4 3 2 1
7 8 5 6 3 4 1 2
5 6 7 8 1 2 3 4
1 2 3 4 5 6 7 8
8
Sorting - QuickSort
  • left lt pivot lt right
  • moving 7 (32) 1 13 times

8 7 6 5 4 3 2 1
4 3 2 1 5 8 7 6
2 1 3 4 5 6 7 8
1 2 3 4 5 6 7 8
9
BubbleSort Algorithm
  • for (int i0 iltarray.length i)
  • for (int j0 jltarray.length-i j)
  • if (arrayigtarrayj)
  • swap arrayi and arrayj

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
  • First-In Last-Out

14
Recursion as Stack
  • First-In Last-Out

hanoi(1, src, aux, dst)
hanoi(2, src, dst, aux)
hanoi(3, src, aux, dst)
hanoi(1, aux, dst, src)
hanoi(2, aux, src, dst)
hanoi(3, src, aux, dst)
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(JFrame)
LayoutManager
Components
Components
Components
19
Thank you!
Write a Comment
User Comments (0)
About PowerShow.com