Algorithms and OOD (CSC 207 2014F) : EBoards
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] - [Learning Outcomes] [FAQ] [Teaching & Learning] [Grading] [Rubric] - [Calendar]
Current: [Assignment] [EBoard] [Lab] [Outline] [Reading]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Readings]
Reference: [Student-Curated Resources] [Java 8 API] [Java 8 Tutorials] [Code Conventions]
Related Courses: [CSC 152 2006S (Rebelsky)] [CSC 207 2014S (Rebelsky)] [CSC 207 2014F (Walker)] [CSC 207 2011S (Weinman)]
Misc: [Submit Questions] - [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] - [Issue Tracker (Course)] [Issue Tracker (Textbook)]
Overview
Predicate class in today's lab. I wrote the lab
before Java included its own such class and have not yet had a chance
to update the code.How do I write that generic method?
public static <T> void printSelected(PrintWriter pen,
Vector<T> vec, Predicate<? super T> pred)
General forms
new INTERFACE()
{
void method1() { ...}
void method2() { ... }
};
new CLASS()
{
void additionalMethod() { ... }
@Override
void override() { ... };
}
Example with predicates
Predicate
Sam needs to rewrite the lab to use something that sounds more GUI oriented (e.g., Greetable -> ButtonMaker; Greeter -> Button; greet -> click).