COMP 303 Lecture Notes - Lecture 11: Strategy Pattern, Iterator Pattern, Nzr Ds Class

31 views6 pages

Document Summary

Outline: about design patterns, the iterator pattern, model view controller style, the observer pattern. Problems may use the same pattern, though the speci c solution is di erent. Patterns are described with: title, short description of application area, long description of the problem, long prescription of the solution methodology. Problem: we want a class to allow us to move from one piece of data to the next. e. g. array, arraylist, linkedlist, scanner, input streams, tree (e. g. Problem: we want a class to allow us to move from one piece of data to the next. e. g. array, arraylist, linkedlist, scanner, input streams, tree (e. g. the pre-ordered traversal in the tree) Iterator allows us to use start(), hasnext(), and next() Iterators do not expose the internal structure of a class. While loop with iterator as a separate class. For loop with iterator in the list class: for (list. reset(); list. hasnext(); list. next()) { Ds x = new ds( ); while (!x. isdone( ) ) {

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents