Today’s topics Java Information Retrieval Upcoming Database Programs

Slides:



Advertisements
Similar presentations
Java GUI building with the AWT. AWT (Abstract Window Toolkit) Present in all Java implementations Described in (almost) every Java textbook Adequate for.
Advertisements

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.
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:
CS3157 Java UI Recitation. Material Covered: Overview of AWT components, Event Handling, creating applets, and sample UI. Not covered in recitation: Drawing,
CPSC150 Abstract Classes and Interfaces Chapter 10.
CS 106 Introduction to Computer Science I 03 / 07 / 2008 Instructor: Michael Eckmann.
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]
CPS Today’s topics Java Information Retrieval Upcoming Database Programs Reading Great Ideas, Chapter 4.
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.
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.
Java Applet Basics (2). The Body Mass Index Calculator.
CompSci Today’s topics Java Applications Simulation Upcoming Software Engineering (Chapter 7) Reading Great Ideas, Chapters 6.
Introduction To JavaScript. Putting it Together (page 11) All javascript must go in-between the script tags. All javascript must go in-between the script.
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.
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.
Strings Methods in the String class Manipulating text in Java.
(c) University of Washington06-1 CSC 143 Java Inheritance Tidbits.
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.
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)
Java Basics Regular Expressions.  A regular expression (RE) is a pattern used to search through text.  It either matches the.
Today’s topics Java Upcoming Reading Recursion in Graphics
CompSci 230 S Programming Techniques
CompSci 280 S Introduction to Software Development
Excel IF Function.
Regular Expressions 'RegEx'.
Today’s topics Java Arrays Upcoming Functions Reading
1-Introduction (Computing the image histogram).
Today’s topics Java Applications Upcoming Reading Graphics
Ellen Walker Hiram College
Binary Search Example with Labeled Indices
GUI building with the AWT
Basics of Classification
Topic 1: Problem Solving
More About Inheritance & Interfaces
CS2110: Software Development Methods
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.
Goals Understand how to create and compare Strings.
Simplifying Expressions
Constructors, GUI’s(Using Swing) and ActionListner
Chapter 7-2 (Book Chapter 14)
Visit for more Learning Resources
Produced by Dave Foord ‘Top 6 Activity’ Produced by Dave Foord
GUI building with the AWT
Probability Lesson 4: Non-Equally Likely Events
Lecture 06 SQL in C#, Project
Java String Class String is a class
#1 #2 #3 Chapter 6 -3 Write an inequality for the sentence:
CSE 326: Data Structures Lecture #14
Presented by : Aman Gupta PGT CS KV No.1, Narimedu, Madurai
Week 6 - Monday CS221.
Java-Assignment #4 (Due, April. 9, 2004)
Presentation transcript:

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

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” “613-1978” “660-6532” “732-7616” “681-6326” “684-8111”

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[]= {"613-1978","660-6532","732-7616", "681-6326","684-8111","613-1978"}; 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");

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; // could also use: size = Name.length; } public void actionPerformed(ActionEvent event) { Object cause = event.getSource(); int k=0;

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(); if (num.equals(Num[k])) mResults.append("Number: " + num + " shows name: " + Name[k] + "\n");

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” E.g., A_C-12_45 (where underscore denotes possible missing data) Require regular expression search This goes beyond what we can easily do

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 (shown briefly earlier) 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 is much more flexible

Search Program public class Search extends java.applet.Applet implements ActionListener { TextField gKey, mInstruct; String Info[]={"J.Able, 613-1978", "D.Ramm, 660-6532", "D.Ramm, 732-7616", "R.Odom, 681-6326", "M.Salter, 684-8111", "W.Tars, 613-1978"}; Button bSearch; TextArea mResults; String key; int size = 6; // or Info.length public void init() { mInstruct = new TextField(60); mInstruct.setText( "Enter search info; push button"); gKey = new TextField(35); bSearch = new Button("Search");

Search Program.2 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;

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