CPS 001 12.1 Today’s topics Java Information Retrieval Upcoming Database Programs Reading Great Ideas, Chapter 4.

Slides:



Advertisements
Similar presentations
Why not just use Arrays? Java ArrayLists.
Advertisements

Java GUI building with the AWT. AWT (Abstract Window Toolkit) Present in all Java implementations Described in (almost) every Java textbook Adequate for.
Searching for Data Relationship between searching and sorting Simple linear searching Linear searching of sorted data Searching for string or numeric data.
CompSci Today’s topics Java Recursion in Graphics Writing a Class Simple Animation Upcoming Simulation Reading Great Ideas, Chapters 5.
The Symbol Table Lecture 13 Wed, Feb 23, The Symbol Table When identifiers are found, they will be entered into a symbol table, which will hold.
CS 180 Problem Solving and Object Oriented Programming Fall 2011 Notes for Week 9: Oct 17-21, 2011 Aditya Mathur Department of Computer Science Purdue.
Lecture 17 Abstract classes Interfaces The Comparable interface Event listeners All in chapter 10: please read it.
CS 178: Programming with Multimedia Objects Aditya P. Mathur Professor of Computer Sciences Purdue University, West Lafayette Sept 9, 2004 Last update:
1 Simple Phone Applet Lab Mobile Phone Display Area Send, Menu and End Numbers 0-9 * and #
Hard Drive Simulation By Steven Hyink Perry Kukura.
Event Handling Events and Listeners Timers and Animation.
CS 206 Introduction to Computer Science II 10 / 14 / 2009 Instructor: Michael Eckmann.
CS3157 Java UI Recitation. Material Covered: Overview of AWT components, Event Handling, creating applets, and sample UI. Not covered in recitation: Drawing,
CS 106 Introduction to Computer Science I 03 / 07 / 2008 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 10 / 15 / 2007 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 10 / 16 / 2006 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 03 / 17 / 2008 Instructor: Michael Eckmann.
1 Functional Testing Motivation Example Basic Methods Timing: 30 minutes.
COSC 2007 Data Structures II
CompSci Today’s topics Java The Database Program Upcoming Recursion Reading Great Ideas, Chapter 4.
CPS Today’s topics Java Language Inheritance Upcoming Electric Circuits (not in text) Reading Great Ideas, Chapters 5.
CSC 142 O 1 CSC 142 Java More About Inheritance & Interfaces [Reading: chapter 13]
CS 106 Introduction to Computer Science I 03 / 19 / 2007 Instructor: Michael Eckmann.
Java GUI building with the AWT. AWT (Abstract Window Toolkit) Present in all Java implementations Described in (almost) every Java textbook Adequate for.
Java Applet Presented by Fitsum Okubu. Introduction Introduction Graphics Graphics Methods and Variables Methods and Variables Events Events Decision.
CompSci Today’s topics Java Review Just a bunch of headings meant to trigger questions A contraction of previous notes Upcoming Midterm Exam Reading.
CS 11 java track: lecture 4 This week: arrays interfaces listener classes inner classes GUI callbacks.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
1 Introduction to Database Systems CSE 444 Lecture 06 SQL in C#, Project October 5, 2007.
7/3/00SEM107- © Kamin & ReddyClass 11 - Events - 1 Class 11 - Events r A couple of odds & ends m Component sizes  switch statement r Event types r Catching.
CompSci Arrays  Aggregate data type  Deal with items of same type  Lists of words  Numbers  Analogies  Mailboxes in post office  CD racks.
MSc Workshop - © S. Kamin, U.Reddy Lect 4 - Events - 1 Lecture 4 – Event Handling r Painting r Event types r Catching different event types.
CPS Today’s topics Java Applications Graphics Upcoming Review for Midterm Exam Reading Great Ideas, Chapters 5.
12/5/00SEM107, Kamin & ReddyReview - 34 Events Event types Catching different event types Getting information from components and events Distinguishing.
1 Lesson: Applets with User Input and Output with GUI ICS4M.
Java Applets: GUI Components, Events, Etc. Ralph Westfall June, 2010.
Chapter 11 Hash Tables © John Urrutia 2014, All Rights Reserved1.
Java Applet Basics (2). The Body Mass Index Calculator.
Introduction to GUI in 1 Graphical User Interface 2 Nouf Almunyif.
Efficient Algorithms for Some Variants of the Farthest String Problem Chih Huai Cheng, Ching Chiang Huang, Shu Yu Hu, Kun-Mao Chao.
CompSci Today’s topics Java Applications Simulation Upcoming Software Engineering (Chapter 7) Reading Great Ideas, Chapters 6.
Kim B. Bruce, Andrea Danyluk & Tom Murtagh Williams College † Partially supported by NSF CCLI grant DUE Java: An Eventful Approach An innovative.
Databases Letts Chapter 11. A database program can be used to:  sort a file into a different order;  search through the records for a matching string.
17/3/00SEM107 © Kamin & Reddy Class 13 - Animation 1 Class 13 - Animation r Summary of loops m while-do m for m do-while r while loop examples r for loop.
Copyright 2010 by Pearson Education Building Java Programs Chapter 10, 11 Lecture 22: 143 Preview optional reading: 10.1,
Week101 APCS-AB: Java Miscellaneous Topics: Snippets we missed in Chapters 1-6 of book November 11, 2005.
SNU OOPSLA Lab. 1 Great Ideas of CS with Java Part 1 WWW & Computer programming in the language Java Ch 1: The World Wide Web Ch 2: Watch out: Here comes.
Key Events in North America Colored Maps Color Key France = red Spain = yellow US = blue Great Britain (England) = green Mexico = purple.
CompSci Today’s topics Java Numbers Iteration Upcoming More Java Reading Great Ideas, Chapter 3.
CompSci Today’s topics Java Writing Functions/Methods Upcoming Information Retrieval Reading Great Ideas, Chapter 4.
(c) University of Washington06-1 CSC 143 Java Inheritance Tidbits.
CompSci 4 Chap 6 Sec 2 Sep 30, 2010 Prof. Susan Rodger “All your troubles are due to those ‘ifs’,” declared the Wizard. If you were not a Flutterbudget.
Discourse community A group of people communication.
Today’s topics Java Input More Syntax Upcoming Decision Trees More formal treatment of grammers Reading Great Ideas, Chapter 2.
Linear Search Linear Search is a fundamental search algorithm. Linear search, also known as sequential search, is a process that checks every element in.
Today’s topics Java Looping Upcoming Arrays in Java Reading Great Ideas, Chapter 3.
Chapter 8: Loops, Arrays, Strings Loop statements –do –while –for Arrays –declaration, allocation, initialization, access –multi-dimensional –heterogeneous.
CompSci Today’s Topics Computer Science Noncomputability Upcoming Special Topic: Enabled by Computer -- Decoding the Human Genome Reading Great.
CompSci Today’s topics Java Recursion Upcoming Graphics Reading Great Ideas, Chapter 4 (begin Chapter 5 for graphics)
Coming up Implementation vs. Interface The Truth about variables Comparing strings HashMaps.
Today’s topics Java Upcoming Reading Recursion in Graphics
Regular Expressions 'RegEx'.
Today’s topics Java Information Retrieval Upcoming Database Programs
Today’s topics Java Arrays Upcoming Functions Reading
Today’s topics Java Applications Upcoming Reading Graphics
GUI building with the AWT
Basics of Classification
More About Inheritance & Interfaces
Binary Search A binary search algorithm finds the position of a specified value within a sorted array. Binary search is a technique for searching an ordered.
Java-Assignment #4 (Due, April. 9, 2004)
Presentation transcript:

CPS Today’s topics Java Information Retrieval Upcoming Database Programs Reading Great Ideas, Chapter 4

CPS Information Retrieval  Often want to use program for information storage and retrieval  On line phone book is good example  Using “Parallel” or “Corresponding Arrays”  Array (of Strings) for Names  Array (of Strings) for Phone Numbers Name Number “J.Able” “D.Ramm” “R.Odom” “M.Salter” “W.Tars” “ ” “ ” “ ” “ ” “ ” “ ”

CPS Phone Lookup Program public class LookUp extends java.applet.Applet implements ActionListener { TextField gName, gNum, mInstruct; String Name[]={"J.Able", "D.Ramm", "D.Ramm", "R.Odom", "M.Salter", "W.Tars"}; String Num[]= {" "," "," ", " "," "," "}; Button bByName, bByNum; TextArea mResults; String name, num; int size; public void init() { mInstruct = new TextField(60); mInstruct.setText( "Enter search info; push related button");

CPS Phone Lookup Program.2 gName = new TextField(25); gNum = new TextField(25); bByName = new Button("ByName"); bByNum = new Button("ByNum"); mResults = new TextArea(10, 60); bByName.addActionListener(this); bByNum.addActionListener(this); add(mInstruct); add(gName); add(bByName); add(gNum); add(bByNum); add(mResults); size = 6; } public void actionPerformed(ActionEvent event) { Object cause = event.getSource(); int k=0;

CPS Phone Lookup Program.3 if (cause == bByName) { name = gName.getText(); while (k < size) { if (name.equals(Name[k])) mResults.append("Name: " + name + " shows number: " + Num[k] + "\n"); k = k + 1; } if (cause == bByNum) { num = gNum.getText(); while (k < size) { if (num.equals(Num[k])) mResults.append("Number: " + num + " shows name: " + Name[k] + "\n"); k = k + 1; }

CPS Shortcomings?  Must enter exact match to one of the entries  Typing “ Ramm” gets no answers  Can’t enter partial number either  Imagine Law Enforcement Application  Partial entries desirable  Solving the “phone list” problems solve it here too  How about license plate with “holes” o E.g., A_C-12_45 (where underscore denotes possible missing data)  Require regular expression search  This goes beyond what we can easily do

CPS Search Using a Single Array  Can solve most of the previous problems easily  Put all relevant info about one phone in one string  Need additional String method  indexOf method int indexOf(String key)  Searches for first occurrence of key with object string  Returns starting position of key: must be greater than or equal to 0 (>=0)  What if it doesn’t find the string (key) sought?  Needs to return something that can’t be mistaken for location of string  ?  Resulting program much more flexible

CPS public class Search extends java.applet.Applet implements ActionListener { TextField gKey, mInstruct; String Info[]={"J.Able, ", "D.Ramm, ", "D.Ramm, ", "R.Odom, ", "M.Salter, ", "W.Tars, "}; Button bSearch; TextArea mResults; String key; int size = 6; public void init() { mInstruct = new TextField(60); mInstruct.setText( "Enter search info; push related button"); gKey = new TextField(35); bSearch = new Button("Search"); Search Program

CPS mResults = new TextArea(10, 60); bSearch.addActionListener(this); add(mInstruct); add(gKey); add(bSearch); add(mResults); } public void actionPerformed(ActionEvent event) { Object cause = event.getSource(); int k=0; if (cause == bSearch) { key = gKey.getText(); while (k < size) { if (Info[k].indexOf(key) >= 0) mResults.append(Info[k]+"\n"); k = k + 1; } Search Program.2

CPS Database  Extend ideas used in phone program  Can have many “parallel” arrays  Design Used Car Database Make Style Color Owner Year “Mercedes” “Ford” “Mercedes” “Datsun” “Ford” “4 door” “truck” “4 door” “2 door” “4 door” “white” “ivory” “blue” “green” “red” “blue” “M.Ramm” “D.Ramm” “M.Ramm” “D.Ramm” “K.Ramm” “D.Ramm”