107 Pages

ICOM4015-lec09-f08

Course: ICOM 4015, Fall 2009
School: UPR Mayagüez
Rating:
 
 
 
 
 

Word Count: 6131

Document Preview

ICOM 4015: Advanced Programming Lecture 9 Chapter Nine: Interfaces and Polymorphism ICOM 4015 Fall 2008 <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley & Sons. All rights reserved. Chapter Nine: Interfaces and Polymorphism <a href="/keyword/big-java/" >big java</a> by...

Register Now

Unformatted Document Excerpt

Coursehero >> United States >> UPR Mayagüez >> ICOM 4015

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
ICOM 4015: Advanced Programming Lecture 9 Chapter Nine: Interfaces and Polymorphism ICOM 4015 Fall 2008 <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Chapter Nine: Interfaces and Polymorphism <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Chapter Goals To learn about interfaces To be able to convert between class and interface references To understand the concept of polymorphism To appreciate how interfaces can be used to decouple classes To learn how to implement helper classes as inner classes To understand how inner classes access variables from the surrounding scope To implement event listeners in graphical applications <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Using Interfaces for Code Reuse Use interface types to make code more reusable In Chapter 6, we created a DataSet to find the average and maximum of a set of values (numbers) What if we want to find the average and maximum of a set of BankAccount values? Continued <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch06/dataset/DataSet.java 01: 02: 03: 04: 05: 06: 07: 08: 09: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: /** Computes the average of a set of data values. */ public class DataSet { /** Constructs an empty data set. */ public DataSet() { sum = 0; count = 0; maximum = 0; } /** Adds a data value to the data set @param x a data value */ public void add(double x) { Continued <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch06/dataset/DataSet.java (cont.) 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: sum = sum + x; if (count == 0 || maximum &lt; x) maximum = x; count++; } /** Gets the average of the added data. @return the average or 0 if no data has been added */ public double getAverage() { if (count == 0) return 0; else return sum / count; } /** Gets the largest of the added data. @return the maximum or 0 if no data has been added */ Continued <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch06/dataset/DataSet.java (cont.) 41: 42: 43: 44: 45: 46: 47: 48: 49: } public double getMaximum() { return maximum; } private double sum; private double maximum; private int count; Output: Enter value, Q Enter value, Q Enter value, Q Enter value, Q Average = 3.0 Maximum = 10.0 to to to to quit: quit: quit: quit: 10 0 -1 Q <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Using Interfaces for Code Reuse (cont.) public class DataSet // Modified for BankAccount objects { . . . public void add(BankAccount x) { sum = sum + x.getBalance(); if (count == 0 || maximum.getBalance() &lt; x.getBalance()) maximum = x; count++; } public BankAccount getMaximum() { return maximum; } private double sum; private BankAccount maximum; private int count; } <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Using Interfaces for Code Reuse Or suppose we wanted to find the coin with the highest value among a set of coins. We would need to modify the DataSet class again: public class DataSet // Modified for Coin objects { . . . public void add(Coin x) { sum = sum + x.getValue(); if (count == 0 || maximum.getValue() &lt; x.getValue()) maximum = x; count++; } Continued <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Using Interfaces for Code Reuse public Coin getMaximum() { return maximum; } private double sum; private Coin maximum; private int count; } <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Using Interfaces for Code Reuse The mechanics of analyzing the data is the same in all cases; details of measurement differ Classes could agree on a method getMeasure that obtains the measure to be used in the analysis We can implement a single reusable DataSet class whose add method looks like this: sum = sum + x.getMeasure(); if (count == 0 || maximum.getMeasure() &lt; x.getMeasure()) maximum = x; count++; Continued <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Using Interfaces for Code Reuse (cont.) What is the type of the variable x? x should refer to any class that has a getMeasure method In Java, an interface type is used to specify required operations public interface Measurable { double getMeasure(); } Interface declaration lists all methods (and their signatures) that the interface type requires <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Interfaces vs. Classes An interface type is similar to a class, but there are several important differences: All methods in an interface type are abstract; they don't have an implementation All methods in an interface type are automatically public An interface type does not have instance fields <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Generic DataSet for Measurable Objects public class DataSet { . . . public void add(Measurable x) { sum = sum + x.getMeasure(); if (count == 0 || maximum.getMeasure() &lt; x.getMeasure()) maximum = x; count++; } public Measurable getMaximum() { return maximum; } Continued <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Generic DataSet for Measurable Objects private double sum; private Measurable maximum; private int count; } <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Implementing an Interface Type Use implements keyword to indicate that a class implements an interface type public class BankAccount implements Measurable { public double getMeasure() { return balance; } // Additional methods and fields } A class can implement more than one interface type Class must define all the methods that are required by all the interfaces it implements Continued <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Implementing an Interface Type (cont.) Use implements keyword to indicate that a class implements an interface type public class BankAccount implements Measurable { public double getMeasure() { return balance; } // Additional methods and fields } A class can implement more than one interface type Class must define all the methods that are required by all the interfaces it implements <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. UML Diagram of DataSet and Related Classes Interfaces can reduce the coupling between classes UML notation: Interfaces are tagged with a &quot;stereotype&quot; indicator interface A dotted arrow with a triangular tip denotes the &quot;is-a&quot; relationship between a class and an interface A dotted line with an open v-shaped arrow tip denotes the &quot;uses&quot; relationship or dependency Note that DataSet is decoupled from BankAccount and Coin <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Syntax 9.1 Defining an Interface public interface InterfaceName { // method signatures } Example: public interface Measurable { double getMeasure(); } Purpose: To define an interface and its method signatures. The methods are automatically public. <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Syntax 9.2 Implementing an Interface public class ClassName implements InterfaceName, InterfaceName, ... { // methods // instance variables } Example: public class BankAccount implements Measurable { // Other BankAccount methods public double getMeasure() { // Method implementation } Continued } <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Syntax 9.2 Implementing an Interface (cont.) Purpose: To define a new class that implements the methods of an interface. <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch09/measure1/DataSetTester.java 01: 02: 03: 04: 05: 06: 07: 08: 09: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: /** This program tests the DataSet class. */ public class DataSetTester { public static void main(String[] args) { DataSet bankData = new DataSet(); bankData.add(new BankAccount(0)); bankData.add(new BankAccount(10000)); bankData.add(new BankAccount(2000)); System.out.println(&quot;Average balance: &quot; + bankData.getAverage()); System.out.println(&quot;Expected: 4000&quot;); Measurable max = bankData.getMaximum(); System.out.println(&quot;Highest balance: &quot; + max.getMeasure()); System.out.println(&quot;Expected: 10000&quot;); <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch09/measure1/DataSetTester.java (cont.) 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: } DataSet coinData = new DataSet(); coinData.add(new Coin(0.25, &quot;quarter&quot;)); coinData.add(new Coin(0.1, &quot;dime&quot;)); coinData.add(new Coin(0.05, &quot;nickel&quot;)); System.out.println(&quot;Average coin value: &quot; + coinData.getAverage()); System.out.println(&quot;Expected: 0.133&quot;); max = coinData.getMaximum(); System.out.println(&quot;Highest coin value: &quot; + max.getMeasure()); System.out.println(&quot;Expected: 0.25&quot;); } <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch09/measure1/DataSetTester.java (cont.) Output: Average balance: 4000.0 Expected: 4000 Highest balance: 10000.0 Expected: 10000 Average coin value: 0.13333333333333333 Expected: 0.133 Highest coin value: 0.25 Expected: 0.25 <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Self Check 9.1 Suppose you want to use the DataSet class to find the Country object with the largest population. What condition must the Country class fulfill? Answer: It must implement the Measurable interface, and its getMeasure method must return the population. <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Self Check 9.2 Why can't the add method of the DataSet class have a parameter of type Object? Answer: The Object class doesn't have a getMeasure method, and the add method invokes the getMeasure method. <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Converting Between Class and Interface Types You can convert from a class type to an interface type, provided the class implements the interface BankAccount account = new BankAccount(10000); Measurable x = account; // OK Coin dime = new Coin(0.1, &quot;dime&quot;); Measurable x = dime; // Also OK Cannot convert between unrelated types Measurable x = new Rectangle(5, 10, 20, 30); // ERROR Because Rectangle doesn't implement Measurable <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Casts Add coin objects to DataSet DataSet coinData coinData.add(new coinData.add(new . . . Measurable max = largest coin = new DataSet(); Coin(0.25, &quot;quarter&quot;)); Coin(0.1, &quot;dime&quot;)); coinData.getMaximum(); // Get the What can you do with it? It's not of type Coin String name = max.getName(); // ERROR You need a cast to convert from an interface type to a class type You know it's a coin, but the compiler doesn't. Apply a cast: Coin maxCoin = (Coin) max; String name = maxCoin.getName(); Continued <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Casts (cont.) If you are wrong and max isn't a coin, the compiler throws an exception Difference with casting numbers: When casting number types you agree to the information loss When casting object types you agree to that risk of causing an exception <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Self Check 9.3 Can you use a cast (BankAccount) x to convert a Measurable variable x to a BankAccount reference? Answer: Only if x actually refers to a BankAccount object. <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Self Check 9.4 If both BankAccount and Coin implement the Measurable interface, can a Coin reference be converted to a BankAccount reference? Answer: No a Coin reference can be converted to a Measurable reference, but if you attempt to cast that reference to a BankAccount, an exception occurs. <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Polymorphism Interface variable holds reference to object of a class that implements the interface Measurable x; x = new BankAccount(10000); x = new Coin(0.1, &quot;dime&quot;); Note that the object to which x refers doesn't have type Measurable; the type of the object is some class that implements the Measurable interface You can call any of the interface methods: double m = x.getMeasure(); Which method is called? <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Polymorphism Depends on the actual object If x refers to a bank account, calls BankAccount.getMeasure If x refers to a coin, calls Coin.getMeasure Polymorphism (many shapes): Behavior can vary depending on the actual type of an object Called late binding: resolved at runtime Different from overloading; overloading is resolved by the compiler (early binding) <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Animation 9.1 <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Self Check 9.5 Why is it impossible to construct a Measurable object? Answer: Measurable is an interface. Interfaces have no fields and no method implementations. <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Self Check 9.6 Why can you nevertheless declare a variable whose type is Measurable? Answer: That variable never refers to a Measurable object. It refers to an object of some class a class that implements the Measurable interface. <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Self Check 9.7 What do overloading and polymorphism have in common? Where do they differ? Answer: Both describe a situation where one method name can denote multiple methods. However, overloading is resolved early by the compiler, by looking at the types of the parameter variables. Polymorphism is resolved late, by looking at the type of the implicit parameter object just before making the call. <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Using Interfaces for Callbacks Limitations of Measurable interface: Can add Measurable interface only to classes under your control Can measure an object in only one way E.g., cannot analyze a set of savings accounts both by bank balance and by interest rate Callback mechanism: allows a class to call back a specific method when it needs more information In previous DataSet implementation, responsibility of measuring lies with the added objects themselves Continued <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Using Interfaces for Callbacks (cont.) Alternative: Hand the object to be measured to a method: public interface Measurer { double measure(Object anObject); } Object is the &quot;lowest common denominator&quot; of all classes <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Using Interfaces for Callbacks method asks measurer (and not the added object) to do the measuring: add public void add(Object x) { sum = sum + measurer.measure(x); if (count == 0 || measurer.measure(maximum) &lt; measurer.measure(x)) maximum = x; count++; } <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Using Interfaces for Callbacks You can define measurers to take on any kind of measurement public class RectangleMeasurer implements Measurer { public double measure(Object anObject) { Rectangle aRectangle = (Rectangle) anObject; double area = aRectangle.getWidth() * aRectangle.getHeight(); return area; } } Must cast from Object to Rectangle Rectangle aRectangle = (Rectangle) anObject; Continued <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Using Interfaces for Callbacks (cont.) Pass measurer to data set constructor: Measurer m = DataSet data data.add(new data.add(new new RectangleMeasurer(); = new DataSet(m); Rectangle(5, 10, 20, 30)); Rectangle(10, 20, 30, 40)); . . . <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. UML Diagram of Measurer Interface and Related Classes Note that the Rectangle class is decoupled from the Measurer interface <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch09/measure2/DataSet.java 01: /** 02: Computes the average of a set of data values. 03: */ 04: public class DataSet 05: { 06: /** 07: Constructs an empty data set with a given measurer. 08: @param aMeasurer the measurer that is used to measure data values 09: */ 10: public DataSet(Measurer aMeasurer) 11: { 12: sum = 0; 13: count = 0; 14: maximum = null; 15: measurer = aMeasurer; 16: } 17: 18: /** 19: Adds a data value to the data set. 20: @param x a data value Continued 21: */ <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch09/measure2/DataSet.java (cont.) 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: public void add(Object x) { sum = sum + measurer.measure(x); if (count == 0 || measurer.measure(maximum) &lt; measurer.measure(x)) maximum = x; count++; } /** Gets the average of the added data. @return the average or 0 if no data has been added */ public double getAverage() { if (count == 0) return 0; else return sum / count; } Continued <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch09/measure2/DataSet.java (cont.) 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: } /** Gets the largest of the added data. @return the maximum or 0 if no data has been added */ public Object getMaximum() { return maximum; } private private private private double sum; Object maximum; int count; Measurer measurer; <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch09/measure2/DataSetTester2.java 01: 02: 03: 04: 05: 06: 07: 08: 09: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: import java.awt.Rectangle; /** This program demonstrates the use of a Measurer. */ public class DataSetTester2 { public static void main(String[] args) { Measurer m = new RectangleMeasurer(); DataSet data = new DataSet(m); data.add(new Rectangle(5, 10, 20, 30)); data.add(new Rectangle(10, 20, 30, 40)); data.add(new Rectangle(20, 30, 5, 15)); System.out.println(&quot;Average area: &quot; + data.getAverage()); System.out.println(&quot;Expected: 625&quot;); Continued <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch09/measure2/DataSetTester2.java (cont.) 21: Rectangle max = (Rectangle) data.getMaximum(); 22: System.out.println(&quot;Maximum area rectangle: &quot; + max); 23: System.out.println(&quot;Expected: java.awt.Rectangle[x=10,y=20,width=30,height=40]&quot;); 24: } 25: } <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch09/measure2/Measurer.java 01: 02: 03: 04: 05: 06: 07: 08: 09: 10: 11: 12: /** Describes any class whose objects can measure other objects. */ public interface Measurer { /** Computes the measure of an object. @param anObject the object to be measured @return the measure */ double measure(Object anObject); } <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch09/measure2/RectangleMeasurer.java 01: 02: 03: 04: 05: 06: 07: 08: 09: 10: 11: 12: 13: 14: import java.awt.Rectangle; /** Objects of this class measure rectangles by area. */ public class RectangleMeasurer implements Measurer { public double measure(Object anObject) { Rectangle aRectangle = (Rectangle) anObject; double area = aRectangle.getWidth() * aRectangle.getHeight(); return area; } } <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch09/measure2/RectangleMeasurer.java (cont.) Output: Average area: 625 Expected: 625 Maximum area rectangle:java.awt.Rectangle[x=10,y=20, width=30,height=40] Expected: java.awt.Rectangle[x=10,y=20,width=30,height=40] <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Self Check 9.8 Suppose you want to use the DataSet class of Section 9.1 to find the longest String from a set of inputs. Why can't this work? Answer: The String class doesn't implement the Measurable interface. <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Self Check 9.10 Why does the measure method of the Measurer interface have one more parameter than the getMeasure method of the Measurable interface? Answer: A measurer measures an object, whereas getMeasure measures &quot;itself&quot;, that is, the implicit parameter. <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Inner Classes Trivial class can be defined inside a method public class DataSetTester3 { public static void main(String[] args) { class RectangleMeasurer implements Measurer { . . . } Measurer m = new RectangleMeasurer(); DataSet data = new DataSet(m); . . . } } Continued <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Inner Classes (cont.) If inner class is defined inside an enclosing class, but outside its methods, it is available to all methods of enclosing class Compiler turns an inner class into a regular class file: DataSetTester$1$RectangleMeasurer.class <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Syntax 9.3 Inner Classes Declared inside a method class OuterClassName { method signature { . . . class InnerClassName { // methods // fields } . . . } . . . } Declared inside the class class OuterClassName { // methods // fields accessSpecifier class InnerClassName { // methods // fields } . . . } Continued <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Syntax 9.3 Inner Classes Example: public class Tester { public static void main(String[] args) { class RectangleMeasurer implements Measurer { . . . } . . . } } Purpose: To define an inner class whose scope is restricted to a single method or the methods of a single class. <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch09/measure3/DataSetTester3.java 01: 02: 03: 04: 05: 06: 07: 08: 09: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: import java.awt.Rectangle; /** This program demonstrates the use of an inner class. */ public class DataSetTester3 { public static void main(String[] args) { class RectangleMeasurer implements Measurer { public double measure(Object anObject) { Rectangle aRectangle = (Rectangle) anObject; double area = aRectangle.getWidth() * aRectangle.getHeight(); return area; } } Continued <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch09/measure3/DataSetTester3.java (cont.) 21: Measurer m = new RectangleMeasurer(); 22: 23: DataSet data = new DataSet(m); 24: 25: data.add(new Rectangle(5, 10, 20, 30)); 26: data.add(new Rectangle(10, 20, 30, 40)); 27: data.add(new Rectangle(20, 30, 5, 15)); 28: 29: System.out.println(&quot;Average area: &quot; + data.getAverage()); 30: System.out.println(&quot;Expected: 625&quot;); 31: 32: Rectangle max = (Rectangle) data.getMaximum(); 33: System.out.println(&quot;Maximum area rectangle: &quot; + max); 34: System.out.println(&quot;Expected: java.awt.Rectangle[x=10,y=20,width=30,height=40]&quot;); 35: } 36: } <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Self Check 9.11 Why would you use an inner class instead of a regular class? Answer: Inner classes are convenient for insignificant classes. Also, their methods can access variables and fields from the surrounding scope. <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Self Check 9.12 How many class files are produced when you compile the DataSetTester3 program? Answer: Four: one for the outer class, one for the inner class, and two for the DataSet and Measurer classes. <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Operating Systems <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Events, Event Sources, and Event Listeners User interface events include key presses, mouse moves, button clicks, and so on Most programs don't want to be flooded by boring events A program can indicate that it only cares about certain specific events Event listener: Notified when event happens Belongs to a class that is provided by the application programmer Its methods describe the actions to be taken when an event occurs A program indicates which events it needs to receive by installing event listener objects Event source: Event sources report on events When an event occurs, the event source notifies all event listeners <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Events, Event Sources, and Event Listeners Example: Use JButton components for buttons; attach an ActionListener to each button ActionListener interface: public interface ActionListener { void actionPerformed(ActionEvent event); } Need to supply a class whose actionPerformed method contains instructions to be executed when button is clicked event parameter contains details about the event, such as the time at which it occurred Continued <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Events, Event Sources, and Event Listeners (cont.) Construct an object of the listener and add it to the button: ActionListener listener = new ClickListener(); button.addActionListener(listener); <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch09/button1/ClickListener.java 01: 02: 03: 04: 05: 06: 07: 08: 09: 10: 11: 12: 13: import java.awt.event.ActionEvent; import java.awt.event.ActionListener; /** An action listener that prints a message. */ public class ClickListener implements ActionListener { public void actionPerformed(ActionEvent event) { System.out.println(&quot;I was clicked.&quot;); } } <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch09/button1/ButtonViewer.java 01: 02: 03: 04: 05: 06: 07: 08: 09: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; /** This program demonstrates how to install an action listener. */ public class ButtonViewer { public static void main(String[] args) { JFrame frame = new JFrame(); JButton button = new JButton(&quot;Click me!&quot;); frame.add(button); ActionListener listener = new ClickListener(); button.addActionListener(listener); frame.setSize(FRAME_WIDTH, FRAME_HEIGHT); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } Continued <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch09/button1/ButtonViewer.java (cont.) 23: 24: 25: 26: } private static final int FRAME_WIDTH = 100; private static final int FRAME_HEIGHT = 60; Output: <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Self Check 9.13 Which objects are the event source and the event listener in the ButtonViewer program? Answer: The button object is the event source. The listener object is the event listener. <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Self Check 9.14 Why is it legal to assign a ClickListener object to a variable of type ActionListener? Answer: The ClickListener class implements the ActionListener interface. <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Using Inner Classes for Listeners Implement simple listener classes as inner classes like this: JButton button = new JButton(&quot;. . .&quot;); // This inner class is declared in the same method as the button variable class MyListener implements ActionListener { . . . }; ActionListener listener = new MyListener(); button.addActionListener(listener); This places the trivial listener class exactly where it is needed, without cluttering up the remainder of the project Methods of an inner class can access local variables from surrounding blocks and fields from surrounding classes <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Using Inner Classes for Listeners Local variables that are accessed by an inner class method must be declared as final Example: add interest to a bank account whenever a button is clicked: JButton button = new JButton(&quot;Add Interest&quot;); final BankAccount account = new BankAccount(INITIAL_BALANCE); // This inner class is declared in the same method as the account // and button variables. class AddInterestListener implements ActionListener { Continued <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Using Inner Classes for Listeners (cont.) public void actionPerformed(ActionEvent event) { // The listener method accesses the account variable // from the surrounding block double interest = account.getBalance() * INTEREST_RATE / 100; account.deposit(interest); } }; ActionListener listener = new AddInterestListener(); button.addActionListener(listener); <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch09/button2/InvestmentViewer1.java 01: 02: 03: 04: 05: 06: 07: 08: 09: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: import import import import /** This program demonstrates how an action listener can access a variable from a surrounding block. */ public class InvestmentViewer1 { public static void main(String[] args) { JFrame frame = new JFrame(); // The button to trigger the calculation JButton button = new JButton(&quot;Add Interest&quot;); frame.add(button); java.awt.event.ActionEvent; java.awt.event.ActionListener; javax.swing.JButton; javax.swing.JFrame; Continued <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch09/button2/InvestmentViewer1.java (cont.) 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: // The application adds interest to this bank account final BankAccount account = new BankAccount(INITIAL_BALANCE); class AddInterestListener implements ActionListener { public void actionPerformed(ActionEvent event) { // The listener method accesses the account variable // from the surrounding block double interest = account.getBalance() * INTEREST_RATE / 100; account.deposit(interest); System.out.println(&quot;balance: &quot; + account.getBalance()); } } ActionListener listener = new AddInterestListener(); button.addActionListener(listener); Continued <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch09/button2/InvestmentViewer1.java (cont.) 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: } frame.setSize(FRAME_WIDTH, FRAME_HEIGHT); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } private static final double INTEREST_RATE = 10; private static final double INITIAL_BALANCE = 1000; private static final int FRAME_WIDTH = 120; private static final int FRAME_HEIGHT = 60; Output: balance: 1100.0 balance: 1210.0 balance: 1331.0 balance: 1464.1 <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Self Check 9.15 Why would an inner class method want to access a variable from a surrounding scope? Answer: Direct access is simpler than the alternative passing the variable as a parameter to a constructor or method. <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Self Check 9.16 Why would an inner class method want to access a variable from a surrounding If an inner class accesses a local variable from a surrounding scope, what special rule applies? Answer: The local variable must be declared as final. <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Building Applications with Buttons Example: investment viewer program; whenever button is clicked, interest is added, and new balance is displayed Continued <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Building Applications with Buttons (cont.) Construct an object of the JButton class: JButton button = new JButton(&quot;Add Interest&quot;); We need a user interface component that displays a message: JLabel label = new JLabel(&quot;balance: &quot; + account.getBalance()); Use a JPanel container to group multiple user interface components together: JPanel panel = new JPanel(); panel.add(button); panel.add(label); frame.add(panel); <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Building Applications with Buttons Listener class adds interest and displays the new balance: class AddInterestListener implements ActionListener { public void actionPerformed(ActionEvent event) { double interest = account.getBalance() * INTEREST_RATE / 100; account.deposit(interest); label.setText(&quot;balance=&quot; + account.getBalance()); } } Add AddInterestListener as inner class so it can have access to surrounding final variables (account and label) <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch09/button3/InvestmentViewer2.java 01: 02: 03: 04: 05: 06: 07: 08: 09: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: import import import import import import import /** This program displays the growth of an investment. */ public class InvestmentViewer2 { public static void main(String[] args) { JFrame frame = new JFrame(); // The button to trigger the calculation JButton button = new JButton(&quot;Add Interest&quot;); java.awt.event.ActionEvent; java.awt.event.ActionListener; javax.swing.JButton; javax.swing.JFrame; javax.swing.JLabel; javax.swing.JPanel; javax.swing.JTextField; Continued <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch09/button3/InvestmentViewer2.java (cont.) 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: // The application adds interest to this bank account final BankAccount account = new BankAccount(INITIAL_BALANCE); // The label for displaying the results final JLabel label = new JLabel( &quot;balance: &quot; + account.getBalance()); // The panel that holds the user interface components JPanel panel = new JPanel(); panel.add(button); panel.add(label); frame.add(panel); class AddInterestListener implements ActionListener { public void actionPerformed(ActionEvent event) { double interest = account.getBalance() * INTEREST_RATE / 100; Continued <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. ch09/button3/InvestmentViewer2.java (cont.) 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: } account.deposit(interest); label.setText( &quot;balance: &quot; + account.getBalance()); } } ActionListener listener = new AddInterestListener(); button.addActionListener(listener); frame.setSize(FRAME_WIDTH, FRAME_HEIGHT); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } private static final double INTEREST_RATE = 10; private static final double INITIAL_BALANCE = 1000; private static final int FRAME_WIDTH = 400; private static final int FRAME_HEIGHT = 100; <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Self Check 9.17 How do you place the &quot;balance: . . .&quot; message to the left of the &quot;Add Interest&quot; button? Answer: First add label to the panel, then add button. <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Self Check 9.18 Why was it not necessary to declare the button variable as final? Answer: The actionPerformed method does not access that variable. <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Processing Timer Events javax.swing.Timer generates equally spaced timer events Useful whenever you want to have an object updated in regular intervals Sends events to action listener public interface ActionListener { void actionPerformed(ActionEvent event); } Continued <a href="/keyword/big-java/" >big java</a> by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved. Processing Timer Events (cont.) Define a class that implements the ActionListener interface class MyListener implements ActionListener { void actionPerformed(ActionEvent event) { // This action will be executed at each timer event Place listener action here } } Add listener to timer My...

Textbooks related to the document above:
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

UPR Mayagüez - ICOM - 4015
ICOM 4015: Advanced ProgrammingLecture 10Chapter Ten: InheritanceICOM 4015 Fall 2008Big Java by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved.Chapter Ten: InheritanceBig Java by Cay Horstmann Copyright 2008 by John
UPR Mayagüez - ICOM - 4015
ICOM 4015: Advanced ProgrammingLecture 13Chapter Thirteen: RecursionICOM 4015 Fall 2008Big Java by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved.Chapter Thirteen: RecursionBig Java by Cay Horstmann Copyright 2008 b
UPR Mayagüez - ICOM - 4015
ICOM 4015: Advanced ProgrammingLecture 14Chapter Fourteen: Sorting and SearchingICOM 4015 Fall 2008Big Java by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved.Chapter Fourteen: Sorting and SearchingBig Java by Cay Hor
UPR Mayagüez - INEL - 4206
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|15 Jan 2003 14:53:06 -0000 vti_extenderversion:SR|5.0.2.3409 vti_title:SR|Department of Electrical and Computer Engineering vti_assignedto:SR| vti_approvallevel:SR| vti_backlinkinfo:VX|courses/spring200
UPR Mayagüez - ICOM - 4029
Department of Electrical and Computer Engineering University of Puerto Rico Mayagez CampusICOM 4029 Compilers Fall 2003Prof: Bienvenido Vlez Asistente: Arturo SilvaLaboratorio N 2: Ejecutando FLEX bajo LinuxObjetivos1. Entender la metodologa
UPR Mayagüez - ICOM - 4036
The Nature of ComputingICOM 4036 Lecture 2Prof. Bienvenido VelezSpring 2007ICOM 4036 Programming Laguages Lecture 21Some Inaccurate Yet Popular Perceptions of Computing Computing = Computers Computing = Programming Computing = Software
UPR Mayagüez - ICOM - 4036
Universidad de Puerto Rico Recinto Universitario de Mayagez Departamento de Ingeniera Elctrica y ComputadorasICOM 4036 Programming LanguagesOtoo 2004 Ejercicios de prctica Examen Parcial I 1. Add a STACK pointer register to the Easy I Data Path.
UPR Mayagüez - ICOM - 4036
ICOM 4036: PROGRAMMING LANGUAGESLecture 5 Functional Programming The Case of Scheme 05/17/09Required Readings Texbook (Scott PLP) Chapter 11 Section 2: Functional Programming Scheme Language Description Revised Report on the Algorithmic Langu
UPR Mayagüez - INEL - 4206
Universidad de Puerto Rico Recinto Universitario de MayagezINEL 4206 MicroprocesadoresPrimavera 2002 Ejercicios de prctica Examen Parcial I 1. Processor Implementation. Add an instruction BrL (Branch and link) to the Easy I processor designed in
UPR Mayagüez - INEL - 4206
INEL 4206 Fall 2002 Exmen I Nombre: _5/17/09 Seccin: _Anota tu nombre y nmero de seccin en todas las hojas del examen AHORA! (penalidad de 5 puntos)Tienes 2 horas para completar tres problemas. Lee cuidadosamente todo el examen antes de empezar
UPR Mayagüez - INEL - 4206
INEL 4206 Fall 2002 Exmen I Nombre: _5/17/09Anota tu nombre y nmero de seccin en todas las hojas del examen AHORA! (penalidad de 5 puntos)Tienes 2 horas para completar todos los problemas. Lee cuidadosamente todo el examen antes de empezar a tra
UPR Mayagüez - ICOM - 4015
ICOM 4015 Advanced ProgrammingLecture 9 Data Abstraction II Class Specialization Subtype PolymorphismProf. Bienvenido Vlez05/17/09ICOM 40151Inheritance Subtype Polymorphism Outline Defining derived classes Member inheritance Method over
UPR Mayagüez - INEL - 4206
Easy IControl Unit(Level 3 Flowcharts) fetchop1DI&lt;0:9&gt; ABUS AOFetchOpfetchop2AO EAB EDB DI00 11x00 00x00 branch on opcode 100 101 0000 01000 011opcodeaoprsoprloadstorebrnjumpFall 2002INEL 4206 Microprocessors
UPR Mayagüez - INEL - 4206
The Nature of ComputingINEL 4206 Microprocessors Lecture 2Bienvenido Vlez Ph. D. School of Engineering University of Puerto Rico - MayagezSome Inaccurate (Although Popular) Perceptions of Computing Computing = (Electronic) Computers Computing
UPR Mayagüez - ICOM - 4036
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|15 Jan 2004 16:25:08 -0000 vti_extenderversion:SR|5.0.2.4330 vti_title:SR|Department of Electrical and Computer Engineering vti_syncwith_ece.uprm.edu\:21/public_html:TX|15 Jan 2004 16:25:08 -0000 vti_sy
UPR Mayagüez - INEL - 4206
Universidad de Puerto Rico Recinto Universitario de MayagezINEL 4206 MicroprocesadoresPrimavera 2002 Ejercicios de prctica Examen Parcial I 1. Processor Implementation. Add an instruction BrL (Branch and link) to the Easy I processor designed in
UPR Mayagüez - INEL - 4206
INEL 4206 Spring 2002 Exmen II Nombre: _5/17/09 Seccin: _Anota tu nombre y nmero de seccin en todas las hojas del examen AHORA! (penalidad de 5 puntos)Tienes 2 horas para completar tres problemas. Lee cuidadosamente todo el examen antes de empez
UPR Mayagüez - ICOM - 4036
Universidad de Puerto Rico Recinto Universitario de MayagezICOM 4036 Programming LanguagesOtoo 2003 Ejercicios de prctica Examen Parcial II 1. Write a logic program in Prolog to compute the greatest common divisor (GCD) of 2 integer arguments. Th
UPR Mayagüez - ICOM - 4029
Programming Assignments Dates Happy Hour October 15 November 22 December 14-16PA 3 (Parser) 4a (Semantic Analyzer) 4b 5a (Code Generator) 5bHand-out Date September 29 October 11 October 25 November 15 November 29Deadline October 11 October 25 N
UPR Mayagüez - INEL - 4206
Evaluacion Curso INEL 4206 Segundo Examen.Menciona los aspectos que ms te gustan de la clase INEL 4206 en orden decreciente de importancia.AspectoEl uso de las transparencias en la clase y tener un buen Web-Site para el curso.Porcentaje37.09
UPR Mayagüez - INEL - 4206
Universidad de Puerto Rico Mayaguez Department of Electrical and Computer Engineering INEL 4206 Microprocessors Exam III Summary of Topics Review all previous material up to Exam II Procedures o Parameter Passing o Stack frames o Recursive proce
UPR Mayagüez - ICOM - 4015
Sus contestaciones al problemario 2 deben ser entregadas electrnicamente por e-mail siguiendo las siguientes instrucciones.0. Crear un directorio para almacenar los archivos relacionados con cadaproblemario. No tiene que hacer este paso si ya lo h
UPR Mayagüez - ICOM - 4015
Department of Electrical and Computer Engineering University of Puerto Rico Mayagez ICOM 4015 Advanced Programming Fall 2006 Exam I Practice Exercises and Problem Set 1 DUE: September 14, 2006 In class 1) Create a new Eclipse project titled icom4015
UPR Mayagüez - ICOM - 4036
vti_encoding:SR|utf8-nl vti_author:SR|BVWS\bvelez vti_modifiedby:SR|BVWS\bvelez vti_timelastmodified:TR|15 Aug 2005 18:50:12 -0000 vti_timecreated:TR|08 Nov 2004 11:08:29 -0000 vti_title:SR|Universidad de Puerto Rico vti_extenderversion:SR|5.0.2.6417
UPR Mayagüez - ICOM - 4036
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|29 Aug 2005 18:28:44 -0000 vti_extenderversion:SR|5.0.2.6417 vti_author:SR|CHURCH\bvelez vti_modifiedby:SR|BVWS\bvelez vti_timecreated:TR|20 Jan 2004 16:01:58 -0000 vti_title:SR|Chapter 1 vti_nexttolast
UPR Mayagüez - ICOM - 4036
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|18 Oct 2005 18:41:18 -0000 vti_extenderversion:SR|5.0.2.6417 vti_author:SR|CHURCH\bvelez vti_modifiedby:SR|BVWS\bvelez vti_timecreated:TR|04 Sep 2003 17:25:30 -0000 vti_title:SR|Imperative Programming T
UPR Mayagüez - PA - 4029
ICOM 4029 Compiler Writing 1HandoutProgramming Assignment I1 Due Friday, September 3, 2004 at 11:59pmThis assignment asks you to write a short Cool program. The purpose is to acquaint you with the Cool language and to give you experience with so
UPR Mayagüez - ICOM - 4036
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|13 Oct 2004 16:46:56 -0000 vti_extenderversion:SR|5.0.2.6417 vti_author:SR|CHURCH\bvelez vti_modifiedby:SR|BVWS\bvelez vti_timecreated:TR|04 Sep 2003 17:25:30 -0000 vti_title:SR|Imperative Programming T
UPR Mayagüez - ICOM - 4036
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|11 May 2004 18:57:00 -0000 vti_extenderversion:SR|5.0.2.4803 vti_backlinkinfo:VX|courses/Fall2004/icom4036/icom4036.htm courses/Spring2004/icom4036/icom4036.htm vti_author:SR|CHURCH\bvelez vti_modifiedb
UPR Mayagüez - INEL - 4206
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|25 Nov 2002 14:19:52 -0000 vti_extenderversion:SR|5.0.2.3409 vti_author:SR|CHURCH\bvelez vti_modifiedby:SR|CHURCH\bvelez vti_timecreated:TR|22 Nov 2002 13:30:27 -0000 vti_title:SR|Problema vti_assignedt
UPR Mayagüez - ICOM - 4015
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|30 Jan 2001 13:43:12 -0000 vti_extenderversion:SR|4.0.2.4426 vti_backlinkinfo:VX|courses/spring2001/icom4015/icom4015.htm vti_cacheddtm:TX|30 Jan 2001 13:43:12 -0000 vti_filesize:IR|42496 vti_cachedlink
UPR Mayagüez - ICOM - 4015
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|18 Sep 2001 12:37:56 -0000 vti_extenderversion:SR|4.0.2.4426 vti_filesize:IR|60416 vti_title:SR|ICOM 4015 Advanced Programming vti_assignedto:SR| vti_approvallevel:SR| vti_backlinkinfo:VX|courses/fall20
UPR Mayagüez - ICOM - 4015
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|14 Nov 2001 16:22:06 -0000 vti_extenderversion:SR|4.0.2.4426 vti_backlinkinfo:VX|courses/fall2001/icom4015/icom4015.htm vti_filesize:IR|44544 vti_title:SR|ICOM 4015 Advanced Programming vti_syncwith_ece
UPR Mayagüez - PA - 4029
ICOM 4029 Compiler WritingHandout 4Programming Assignment IV1 A Semantic Analyzer for COOLDue Friday, November 14, 2003i.IntroductionIn this assignment you will implement the static semantics of Cool. You will use the abstract syntax trees
UPR Mayagüez - ICOM - 4015
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|02 Oct 2001 15:15:56 -0000 vti_extenderversion:SR|5.0.2.4803 vti_title:SR| vti_backlinkinfo:VX|courses/fall2001/icom4015/icom4015.htm vti_syncwith_ece.uprm.edu\:21/public_html:TX|02 Oct 2001 15:15:56 -0
UPR Mayagüez - ICOM - 4015
vti_encoding:SR|utf8-nl vti_author:SR|Michael vti_timecreated:TR|29 Feb 2000 02:30:38 -0000 vti_timelastmodified:TR|27 Mar 2000 14:32:00 -0000 vti_filesize:IR|50176 vti_title:SR|ICOM 4015 Advanced Programming vti_assignedto:SR| vti_approvallevel:SR|
UPR Mayagüez - ICOM - 4015
vti_encoding:SR|utf8-nl vti_author:SR|Michael vti_timecreated:TR|29 Feb 2000 02:30:38 -0000 vti_timelastmodified:TR|27 Mar 2000 14:32:00 -0000 vti_filesize:IR|59904 vti_title:SR|ICOM 4015 Advanced Programming vti_assignedto:SR| vti_approvallevel:SR|
UPR Mayagüez - ICOM - 4029
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|04 Oct 2004 20:46:56 -0000 vti_extenderversion:SR|5.0.2.6417 vti_author:SR|BVWS\bvelez vti_modifiedby:SR|BVWS\bvelez vti_timecreated:TR|04 Oct 2004 20:46:56 -0000 vti_cacheddtm:TX|04 Oct 2004 20:46:56 -
UPR Mayagüez - ICOM - 4029
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|04 Oct 2004 20:46:56 -0000 vti_extenderversion:SR|5.0.2.6417 vti_author:SR|BVWS\bvelez vti_modifiedby:SR|BVWS\bvelez vti_timecreated:TR|04 Oct 2004 20:46:56 -0000 vti_cacheddtm:TX|04 Oct 2004 20:46:56 -
UPR Mayagüez - ICOM - 4036
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|05 Apr 2005 17:18:26 -0000 vti_extenderversion:SR|5.0.2.6417 vti_author:SR|CHURCH\bvelez vti_modifiedby:SR|BVWS\bvelez vti_timecreated:TR|19 Mar 2004 16:55:12 -0000 vti_title:SR|Universidad de Puerto Ri
UPR Mayagüez - ICOM - 4036
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|08 Nov 2004 11:17:18 -0000 vti_extenderversion:SR|5.0.2.6417 vti_author:SR|BVWS\bvelez vti_modifiedby:SR|BVWS\bvelez vti_timecreated:TR|08 Nov 2004 11:17:18 -0000 vti_cacheddtm:TX|08 Nov 2004 11:17:18 -
UPR Mayagüez - ICOM - 4036
vti_encoding:SR|utf8-nl vti_author:SR|BVWS\bvelez vti_modifiedby:SR|BVWS\bvelez vti_timelastmodified:TR|08 Nov 2004 11:08:29 -0000 vti_timecreated:TR|08 Nov 2004 11:08:29 -0000 vti_cacheddtm:TX|08 Nov 2004 11:02:46 -0000 vti_filesize:IR|36352 vti_cac
UPR Mayagüez - ICOM - 4029
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|27 Aug 2003 18:35:04 -0000 vti_extenderversion:SR|5.0.2.4330 vti_author:SR|CHURCH\bvelez vti_modifiedby:SR|CHURCH\bvelez vti_timecreated:TR|20 Aug 2003 18:05:26 -0000 vti_title:SR|Introduction to Progra
UPR Mayagüez - ICOM - 4036
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|22 Oct 2004 15:27:20 -0000 vti_extenderversion:SR|5.0.2.6417 vti_author:SR|BVWS\bvelez vti_modifiedby:SR|BVWS\bvelez vti_timecreated:TR|22 Oct 2004 15:27:20 -0000 vti_cacheddtm:TX|22 Oct 2004 15:27:20 -
UPR Mayagüez - ICOM - 4036
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|21 Sep 2004 17:24:56 -0000 vti_extenderversion:SR|5.0.2.4803 vti_backlinkinfo:VX|courses/Fall2004/icom4036/icom4036.htm vti_author:SR|CHURCH\bvelez vti_modifiedby:SR|CHURCH\bvelez vti_timecreated:TR|21
UPR Mayagüez - INEL - 4206
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|17 Mar 2003 20:15:32 -0000 vti_extenderversion:SR|5.0.2.3409 vti_author:SR|CHURCH\bvelez vti_modifiedby:SR|CHURCH\bvelez vti_timecreated:TR|17 Mar 2003 14:40:29 -0000 vti_title:SR|Universidad de Puerto
UPR Mayagüez - INEL - 4206
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|19 Mar 2003 13:18:30 -0000 vti_extenderversion:SR|5.0.2.3409 vti_author:SR|CHURCH\bvelez vti_modifiedby:SR|CHURCH\bvelez vti_timecreated:TR|19 Mar 2003 13:18:30 -0000 vti_cacheddtm:TX|19 Mar 2003 13:18: