Chabot College Fall 2004 Replaced Fall 2006 Course Outline for Computer Science 19A OBJECT-ORIENTED PROGRAMMING METHODS IN JAVA Catalog Description: 19A – Object-Oriented Programming Methods In Java 4 Units Object-oriented programming methods employed to design, program, test and document intermediate level problems in the Java language. Overview of Java core classes in Java.lang, language syntax and structure: simple data types, strings, arrays, vectors, loops, decisions, error handling. Classes, inheritance and polymorphism. Introduction to creating graphical user interfaces using the java.awt package. Designed to satisfy ACM guidelines for CS I as required for Computer Science and related transfer majors. Prerequisite: Computer Science 14 (completed with a grade of “C” or higher). Strongly Recommended: Mathematics 20 (completed with a grade of “C” or higher). 3 hours lecture, 3 hours laboratory. Prerequisite Skills: Before entering the course the student should be able to: 1. follow the procedures used in the appropriate college computer laboratory to sign in and out, and to write, edit, compile, run and debug programs; 2. demonstrate steps involved in program development; 3. write simple C++ data types in programs and apply how they are represented in the machine; 4. write C++ expressions using selected operators, and apply the rules of precedence used in their evaluation; 5. apply the structured programming constructs: sequence, selection and iteration; 6. perform elementary interactive input and output operations; 7. code void and value-returning functions with value and reference parameters and use them in a program; 8. define and use the structured C++ data types: array, string, struct in applications drawn from mathematics, the sciences, and other areas; 9. use text files to record and retrieve information in elementary applications; 10. produce well-documented, user-friendly programs of short to medium length. Expected Outcome for Students: Upon completion of the course the student should be able to: 1. create, design, implement, debug, test, and document eight to ten Java applications and applets of intermediate length and complexity that use the full range of Java syntax, selected Java classes, user-defined classes (including those that use the various class associations), and standard GUI components, including at least one simple graphical user interface that can respond to events, using the Java development kit (SDK) and/or other integrated development environments such as JBuilder or Visual Café; 2. use various Java core classes including String, System, Math, and wrapper classes to perform standard System input and output, perform numeric calculations and instantiate and manipulate objects of both Java and user-defined classes; 3. manipulate String and StringBuffer objects, arrays and vectors consisting of simple variables or objects; 4. design Java classes that use visibility modifiers and class (static) variables, overloaded constructors, accessor and general methods; 5. design classes and create and use objects of these classes that bear the following relationships: association ("knows a"), aggregation including composition ("has a"), and inheritance ("is a"); 6. demonstrate familiarity with basic exception handling techniques: try-catch and throw; 7. create and implement an interface; 8. extend an abstract base class and explain the difference. Chabot College Course Outline for Computer Science 19A, Page 2 Fall 2004 Course Content: 1. Java Environment a. Using the SDK and selected Integrated Development Environments to edit, compile, debug, and execute a Java application b. Using the SDK and selected Integrated Development Environments to edit and compile a Java applet and its associated HTML file c. Using a Web browser and AppletViewer to execute an applet 2. JAVA Syntax a. Primitive data types for variables and constants (final) b. Operators c. System input and output – conversion of input to numbers d. Selection and Repetition control structures e. Methods: definition, calling, return types, parameters, call by value, overloaded methods f. Simple recursive methods g. Math class methods 3. Objects and Classes a. Defining a class b. Visibility modifiers c. Scope of variables d. Class (static) variables and methods e. Constructors: definition/significance/use of f. types of constructors: default. parameterized, copy (optional) g. Declaring object references and object instantiation h. Accessing an object’s data and methods and accessor methods i. Passing objects to methods j. The keyword this k. Class relationships: association, aggregation, composition, and inheritance l. Use of wrapper classes m. Casting: conversions between primitive types, between reference types 4. Inheritance a. Superclasses and subclasses b. Use of the keyword super c. Overriding methods d. Abstract classes e. Methods of the Object class: equals, toString, clone (optional) f. Polymorphism and dynamic binding g. Interfaces vs. abstract classes h. Inner classes 5. Designing projects a. Use of Unified Modeling Language for class diagrams b. Guidelines for class design 6. Strings and StringBuffers a. String class 1) Constructing a string object 2) Common methods 3) Substrings 4) Accessing individual characters b. StringBuffer class 1) Comparison with String class 2) Common methods 7. StringTokenizer Class 8. Arrays and vectors a. Declaring, creating and initializing one-dimensional and two-dimensional arrays b. Typical array operations: accessing elements, simple sort and sequential search c. Arrays of objects d. Introduction to the vector class and select methods e. Vector vs. array Chabot College Course Outline for Computer Science 19A, Page 3 Fall 2004 f. Parameters to main 9. Graphics a. The Java Graphics API (Application Program Interface) b. The AWT (Abstract Window Toolkit) vs. Swing c. Frames, containers, components, panels, layout managers, colors d. Drawing geometric figures 10. Introduction to user interfaces a. GUI components: text boxes, labels, scroll bars, buttons, check boxes b. Event driven programming: listeners and event handlers 11. Exception handling 12. Definition 13. Java predefined exception classes 14. User-defined exceptions 15. Claiming an exception: use of throw 16. Handling an exception: try-catch block Methods of Presentation: 1. 2. 3. 4. Lecture Discussion classroom demonstrations Laboratory Methods of Evaluating Student Progress: 1. Typical Assignments a. Construct a Vehicle class. A vehicle has a VIN (Vehicle ID number), year of manufacture, original MSRP, and current blue book value. In each derived class include Strings to store the make and model. Include a reference variable of type Person that represents the vehicle’s owner. For simplicity, assume a Vehicle has only one owner. A new vehicle’s owner is represented by the person reference being null. Construct the usual constructors, and accessor methods, and override the toString method. Supply any other useful methods you desire. b. First do problem 9.24 on p. 452 which is an extension of your inheritance Shape program. In this project, you will actually draw several 2-D figures. You can choose which ones you wish to draw. You can draw rectangle, circle, oval, square using specific methods that belong to all Graphics objects. To draw a triangle, you will have to draw lines to form the sides. 2. Methods of Evaluating Student Progress: a. Minimum of two midterms (or equivalent) and a final exam b. Writing and implementation of various and multiple assigned programs and other assignments which utilize all topics included in the course of study. 3. Textbook(s) (Typical): Introduction to Java Programming, Y. Daniel Liang, Prentice Hall, 2001 Special Student Materials: Portable storage device Carol Conway and Maurice Ngo, September 18, 2001 Revised: 10/96 Carol Conway and Desmond Chun CS 19A Outline Fall 2002 Revised October 2003, Wanda Wong Eff F04