CPE 101 Assignment 4

Study Chapters 8, 9, and 10 of the textbook and do the following exercises.

  1. Do either exercise 8.12 or 8.17. You may also construct another math related class, such as one representing vectors, matrices, or quaternions.

  2. Do GUI exercises 8.1, 9.1, and 10.1

  3. Define abstract, final, and static classes and methods. What is the difference between an abstract class and an interface?

  4. Do exercise 10.10 from the textbook.

  5. Create the beginnings of a schematic capture application. For this purpose, create a set of classes representing common electronic parts (see SPICE program for examples) including a DC source or battery, ground, capacitor, resistor, inductor, diode, and NMOS/PMOS transistors. The data for each class should contain a screen location and orientation (90-degree rotations) and a value (voltage, resistance, etc). You should also provide a node or wire object to be used to connect objects into a circuit diagram. Each object should be able to draw their symbols which provided with a Graphics object that tells them where to draw. Your initial application should instantiate examples of the parts you have designed.

  6. Reflection enables Java code to discover information about the fields, methods and constructors of loaded classes, and to use reflected fields, methods, and constructors to operate on their underlying counterparts, within security restrictions. The program ClassDemo.java (from ClassDemo.zip) illustrates a simple use of the java.lang.reflect classes. Insert the printClassInfo method into Fig. 9.7 BasePlusCommissionEmployeeTest.java or Fig. 9.11 BasePlusCommissionEmployeeTest3.java and use it to print information about instances of the various employee classes.

  7. The java class Class is useful in other ways. Consider the following ClassTrace method (from ClassDemo.zip):
    	void printClass(Object obj) {
    		Class c = obj.getClass();
    		while (c!=null) {
    			System.out.println(c.getName());
    			c = c.getSuperclass();
    		}
    	}
    
    Given a reference to some object obj, this class traces its hierarchy back to java.lang.Object. Write a Java applet that displays the hierarchy of an instance of the class JTextField. Indent each line of the hierarchy like the following example:
    	java.awt.Button
    		java.awt.Component
    			java.awt.Object
    

  8. Consult the API documentation and list the name and purpose of each method of the class Object (which is the root of all classes) that is not associated with threads.


Maintained by John Loomis, last updated 14 Sept 2005