AP Computer Science A Course Design: This syllabus is for a two-semester course, assuming 30 weeks are available prior to the AP exam. The course meets for five 50-minute class periods per week, one of them devoted to individual or group work on lab assignments. The course includes several individual programming projects assigned for one or two weeks each. The time after the AP CS Exam is devoted to enrichment activities such as learning to program cell phones. The course includes units on files, graphics and GUI that are not required for the AP exam. Prerequisite: Computer Programming I, or a grade of B or better in Geometry, or written consent of the instructor is a prerequisite for this course. Course Objectives: • • • • • • • • • • • • • • Understand the basic elements of computer hardware and software and their roles in a computer system; understand the Internet Get familiar with Java syntax and good programming style; learn to pay attention to code clarity and documentation Learn the basics of Java syntax for declaring classes and methods, constants and variables, arithmetic expressions Understand the concept of an algorithm; implement simple algorithms in Java using if-else statements and simple loops Understand the main principles of object-oriented software design and programming Learn to code fluently in Java in a well-structured fashion and in good style; learn to pay attention to code clarity and documentation Learn to use Java library packages and classes within the scope of the AP/A Java subset Understand the concept of an algorithm; implement algorithms in Java using conditional and iterative control structures and recursion Learn common sorting and searching algorithms: Sequential Search and Binary Search, and Selection Sort, Insertion Sort, and Mergesort Understand one- and two-dimensional arrays and the ArrayList class Acquire skills in designing object-oriented software solutions to problems from various application areas Study the Marine Biology Simulation case study and accompanying exercises and questions provided by The College Board Discuss ethical and social issues related to the use of computers Prepare for the A-level AP exam in computer science. 1 Texts and Supplementary Materials: Horstmann, Cay. Java Concepts: Fourth Edition: AP Edition. Wiley Publishing, 2005. Deitel & Associates, Inc. Java: How to Program: Sixth Edition. Pearson/Prentice Hall, 2005. The College Board’s Marine Biology Simulation (MBS) Case Study Manual. Books and articles discussing ethical and social issues related to computer use. Additional resources are available at http://www.horstmann.com/bigjava.html and http://bcs.wiley.com/he-bcs/Books?action=index&itemId=0471697044&bcsId=2215. College Board website for AP Computer Science A (includes links to course description) at http://www.collegeboard.com/student/testing/ap/sub_compscia.html?compscia 2 Course Outline: Chapter numbers for readings and exercises refer to Java Concepts. The labs, case studies, and projects proposed below come from Java Concepts and are subject to change. Topics 1. Introduction 2. Using Objects 3. Implementing Classes 4. Fundamental Data Types 5. Programming Graphics (Optional) 6. Decisions 7. Iteration 8. Arrays and Array Lists 9. Designing Classes 10. Testing and Debugging 11. Interfaces and Polymorphism 12. Event Handling (Optional) 13. Inheritance 14. Graphical User Interfaces 15. Exception Handling 16. Files and Streams 17. Object-Oriented Design 18. Recursion 19. Sorting and Searching 20. Marine Biology Case Study 21. Enrichment Duration (in days) 5 5 5 8 7 8 8 8 7 7 8 (end of first semester) 6 6 6 5 7 6 7 7 20 (varies) Tests will be given as follows: Test 1 (covering chapters 1, 2, and 3) Test 2 (covering chapters 4 and 5) Test 3 (covering chapters 6 and 7) Test 4 (covering chapters 8 and 9) Test 5 (covering chapters 10 and 11) Semester 1 final exam (covering chapters 1 -11 in AP exam format) Test 6 (covering chapters 12 and 13) Test 7 (covering chapters 14 and 15) Test 8 (covering chapters 16 and 17) Test 9 (covering chapters 18 and 19) Test 10 (covering the Case Study) Semester 2 final exam (comprehensive in AP exam format) Note the semester 2 final exam is optional for students taking the AP exam in early May. 3 Topic 1. Introduction (duration 5 days). 1.1 What is programming. 1.2 The Anatomy of a Computer. 1.3 Translating Human Readable Programs to Machine Codes. 1.4 The Java Programming Language. 1.5 Becoming Familiar with Your Computer. 1.6 Compiling a Simple Program. 1.7 Errors. 1.8 The Compilation Project. Goals • • • • • • To understand the activity of programming To learn about the architecture of computers To learn about machine code and high-level programming languages To become familiar with your computing environment and your compiler To compile and run your first Java program To recognize syntax and logic errors Readings Chapter 1 Review Exercises None Programming Exercises P1.6, P1.8 Programming Projects Project 1.1 Labs Lab 1 Supplemental Materials USB (flash) drive or 3.5" floppy disk 4 Topic 2. Using Objects (duration 5 days). 2.1 Types and Variables. 2.2 The Assignment Operator. 2.3 Objects, Classes and Methods. 2.4 Methods, Parameters and Return Values. 2.5 Number Types. 2.6. Constructing Objects. 2.7 Accessor and Mutator (Get and Set) Methods. 2.8 Implementing a Test Program. 2.9 The API Documentation. 2.10 Object References. Goals • • • • • • To learn about variables To understand the concepts of classes and objects To be able to call methods To learn about parameters and return variables To be able to browse the API documentation To realize the difference between objects and object references Readings Chapter 2 Review Exercises R2.6, R2.7, R2.8 Programming Exercises P2.2, P2.4, P2.10 Programming Projects Project 2.2 Labs Lab 2 Supplemental Materials 5 Topic 3. Implementing Classes (duration 5 days). 3.1 Black Boxes. 3.2 Design and Public Interface of a Class. 3.3 Commenting the Public Interface. 3.4 Instance Fields. 3.5 Implementing Constructors and Methods. 3.6 Testing a Class. 3.7 Categories of Variables. 3.8 Implicit and Explicit Method Parameters. Goals • • • • • To become familiar with the process of implementing classes To be able to implement simple methods To understand the purpose and use of constructors To understand how to access instance fields and local variables To appreciate the importance of documentation comments Readings Chapter 3 Review Exercises None Programming Exercises P3.3, P3.9, P3.13 Programming Projects None Labs Lab 3 Supplemental Materials 6 Topic 4. Fundamental Data Types (duration 8 days). 4.1 Number Types. 4.2 Constants. 4.3 Assignment, Increment, and Decrement. 4.4 Arithmetic Operations and Mathematical Functions. 4.5 Calling Static Methods. 4.6 Strings. 4.7 Reading Input. Goals • • • • • • • To understand integer and floating-point numbers To recognize the limitations of the numeric types To become aware of causes for overflow and roundoff errors To understand the proper use of constants To write arithmetic expressions in Java To use the String type to define and manipulate character strings To learn how to read program input and produce formatted output Readings Chapter 4 Review Exercises R4.6, R4.9, R4.11, R4.12, R4.16 Programming Exercises P4.4, P4.8, P4.13, P4.14 Programming Projects Project 4.1 (with a partner) Labs Lab 4 Supplemental Materials 7 Topic 5. Programming Graphics (duration 7 days). 5.1 Frame Windows. 5.2 Drawing Shapes. 5.3 Graphical Shapes. 5.4 Colors. 5.5 Drawing Complex Shapes. 5.6 Reading the Text Input. 5.7 Comparing Visual and Numerical Information. Goals • • • • • • To be able to write simple graphical applications To display graphical shapes, such as lines and ellipses To use colors To display drawings consisting of many shapes To read input from a dialog box To develop test cases that validate the correctness of your programs Readings Chapter 5 Review Exercises None Programming Exercises P5.4, P5.14 Programming Projects Project 5.1 Labs Lab 5 Supplemental Materials 8 Topic 6. Decisions (duration 8 days). 6.1 The if Statement. 6.2 Comparing Values. 6.3 Multiple Alternatives. 6. 4 Using Boolean Expressions. Goals • • • • • To be able to implement decisions using if statements To understand how to group statements into blocks To learn how to compare integers, floating-point numbers, strings, and objects To recognize the correct ordering of decisions in multiple branches To program conditions using Boolean operators and variables Readings Chapter 6 Review Exercises R6.1, R6.5, R6.6, R6.9, R6.10 Programming Exercises P6.1, P6.12, P6.16, P6.17, P6.18 Programming Projects None Labs Lab 6 Supplemental Materials 9 Topic 7. Iteration (duration 8 days). 7.1 while Loops. 7.2 for loops 7.3 Nested Loops 7.4 Processing Sentinel Values. 7.5 Random Numbers and Stimulations. Goals • • • • • To be able to program loops with the while, for, and do statements To avoid infinite loops and off-by-one errors To understand nested loops To learn how to process input To implement simulations Readings Chapter 7 Review Exercises R7.2, R7.4, R7.5, R7.8 Programming Exercises P7.1, P7.2, P7.3, P7.4, P7.18 Programming Projects None Labs Lab 7 Supplemental Materials 10 Topic 8. Arrays and Array Lists (duration 8 days). 8.1 Arrays. 8.2 Arrays Lists. 8.3 Wrappers and Auto-Boxing. 8.4 The Generalized for Loop. 8.5 Simple Array Algorithms. 8.6 Two-Dimensional Arrays. 8.7 Copying Arrays. Goals • • • • • • To become familiar with using arrays and array lists To learn about wrapper classes, auto-boxing, and the enhanced for loop To study common array algorithms To learn how to use two-dimensional arrays To understand when to choose array lists and arrays in your programs To implement partially filled arrays Readings Chapter 8 Review Exercises R8.12, R8.17, R8.18 Programming Exercises P8.13, P8.15, P8.18 Programming Projects Project 8.2 Labs Lab 8 Supplemental Materials 11 Topic 9. Designing Classes (duration 7 days). 9.1 Choosing Classes. 9.2 Cohesion and Coupling. 9.3 Accessors, Mutators, and Immutable Classes. 9.4 Side Effects. 9.5 Preconditions and Postconditions. 9.6 Static Methods. 9.7 Static Fields. 9.8 Scope. 9.9 Packages. Goals • • • • • • • • To learn how to choose appropriate classes to implement To understand the concepts of cohesion and coupling To minimize the use of side effects To document responsibilities of methods and their callers with pre and post conditions To understand the difference between instance methods and static methods To introduce the concept of static fields To understand the scope rules for local variables and instance fields To learn about packages Readings Chapter 9 Review Exercises None Programming Exercises None Programming Projects Project 9.2 Labs Lab 9 Supplemental Materials 12 Topic 10. Testing and Debugging (duration 7 days). 10.1 Unit Tests. 10.2 Providing Test Input. 10.3 Test Case Evaluation. 10.4 Regression Testing and Test Coverage. 10.5 Logging. 10.6 Using a Debugger. 10.7 A Sample Debugging Session. Goals • • • • • To learn how to carry out unit tests To understand the principles of test case selection and evaluation To learn how to use logging To become familiar with using a debugger To learn strategies for effective debugging Readings Chapter 10 Review Exercises None Programming Exercises None Programming Projects Project 10.1 Labs Lab 10 Supplemental Materials 13 Topic 11. Interfaces and Polymorphism (duration 8 days). 11.1 Using Interfaces of Code Reuse. 11.2 Converting Between Class and Interface Types. 11.3 Polymorphism. 11.4 Using Interfaces for Callbacks. 11.5 Inner Classes. 11.6 Processing Timer Events. 11.7 Accessing Surrounding Variables. 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 form the surrounding scope To implement event listeners for timer events Readings Chapter 11 Review Exercises None Programming Exercises P11.15 Programming Projects None Labs Lab 11 Supplemental Materials 14 Topic 12. Event Handling (duration 6 days). 12.1 Events, Event Sources and Event Listeners. 12.2 Building Applications with Buttons. 12.3 Processing Text Input. 12.4 Mouse Events. Goals • To understand the Java event model • To install action and mouse event listeners • To accept input from buttons, text fields, and the mouse Readings Chapter 12 Review Exercises None Programming Exercises P12.9, P12.17 Programming Projects None Labs Lab 12 Supplemental Materials 15 Topic 13. Inheritance (duration 6 days). 13.1 An Introduction to Inheritance. 13.2 Inheritance Hierarchies. 13.3 Inheritance Instance Fields and Methods. 13.4 Subclass Construction. 13.5 Converting between Subclass and Superclass Types. 13.6 Polymorphism. 13.7 Access Control. 13.8 Object: The Cosmic Superclass. Goals • • • • • To learn about inheritance To understand how to inherit and override superclass methods To be able to invoke superclass constructors To learn about protected and package access control To understand the common superclass Object and override toString and equals methods Readings Chapter 13 Review Exercises None Programming Exercises P13.3 Programming Projects None Labs Lab 13 Supplemental Materials 16 Topic 14. Graphical User Interfaces (duration 6 days). 14.1 Using Inheritance to Customize Frames. 14.2 Layout Management. 14.3 Choices. 14.4 Menus. 14.5 Text Areas. 14.6 Exploring the Swing Documentation. Goals • • • • • • To use inheritance to customize frames To understand how user-interface components are added to a container To understand layout managers and arrange user-interface components in a container To become familiar with buttons, combo boxes, text areas, and menus To build programs that handle events form user-interface components To learn how to browse the Java documentation Readings Chapter 14 Review Exercises None Programming Exercises P14.1 Programming Projects None Labs Lab 14 Supplemental Materials 17 Topic 15 Exception Handling (duration 5 days). 15.1 Throwing Exceptions. 15.2 Checked and Unchecked Exceptions. 15.3 Catching Exceptions. 15.4 The finally Clause. 15.5 Designing Your Own Exception Types. 15.6 Case Study: A Complete Example. Goals • • • • • To learn how to throw exceptions To be able to design your own exception classes To understand the difference between checked and unchecked exceptions To learn how to catch exceptions To know when and where to catch an exception Readings Chapter 15 Review Exercises None Programming Exercises None Programming Projects None Labs Lab 15 Supplemental Materials 18 Topic 16. Files and Streams (duration 7 days). 16.1 Reading and Writing Text Files. 16.2 Text and Binary Formats. 16.3 An Encryption Program. 16.4 Random Access. 16.5 Object Streams. Goals • • • • • To be able to read and write text files To become familiar with the concepts of text and binary formats To learn about encryption To understand when to use sequential and random file access To be able to read and write objects using serialization Readings Chapter 16 Review Exercises None Programming Exercises None Programming Projects Macarthur speech text analysis Labs Lab 16 Supplemental Materials 19 Topic 17. Object Oriented Design (duration 6 days). 17.1 The Software Life Cycle. 17.2 Discovering Classes. 17.3 Relationship Between Classes. 17.4 Case Study: Printing an Invoice. 17.5 Case Study: An Automatic Teller Machine. Goals • • • • • • To learn about the software life cycle To learn how to discover new classes and methods To understand the use of CRC cards for class discovery To identify inheritance, aggregation, and dependency relationships between classes To master the use of UML class diagrams to describe class relationships To learn how to use object-oriented design to build complex programs Readings Chapter 17 Review Exercises None Programming Exercises P17.5 Programming Projects None Labs Lab 17 Supplemental Materials 20 Topic 18. Recursion (duration 7 days). 18.1 Triangle Numbers. 18.2 Permutations. 18.3 Recursive Helper Methods. 18.4 Mutual Recursions. 18.5 The Efficiency of Recursion. Goals • • • • • • To learn about the method of recursion To understand the relationship between recursion and iteration To analyze problems that are much easier to solve by recursion than by iteration To learn to think recursively To be able to use recursive helper methods To understand when the use of recursion affects the efficiency of an algorithm Readings Chapter 18 Review Exercises None Programming Exercises P18.4, P18.15 Programming Projects None Labs Lab 18 Supplemental Materials 21 Topic 19. Sorting and Searching (duration 7 days). 19.1 Selection Sort. 19.2 Profiling the Selection Sort Algorithm. 19.3 Analyzing the Performance of the Selection Sort Algorithm. 19.4 Merge Sort. 19.5 Analyzing and Merge Sort Algorithm. 19.6 Searching. 19.7 Binary Search. 19.8 Sorting Real Data. Goals • • • • • To study several sorting and searching algorithms To appreciate that algorithms for the same task can differ widely in performance To understand big-Oh notation To learn how to estimate and compare the performance of algorithms To learn how to measure the running time of a program Readings Chapter 19 Review Exercises None Programming Exercises None Programming Projects None Labs Lab 19 Supplemental Materials 22 Topic 20. Marine Biology Case Study (duration 20 days) Goals • • • • • • Read source code written by someone else. Work with a program of significant length. Become familiar with good coding, design, and documentation practice. Learn about testing in a non-trivial context. Think through design and implementation tradeoffs. Experience an approximation of the master/apprentice relationship. Readings College Board Case Study for AP Computer Science A (now MBCS) Analysis Questions / Exercise Sets (chapters refer to Case Study narrative) Chapter 1 Exercise Sets 1, 2, 3 (all parts) Analysis Questions 1, 2, 3 (all parts) Chapter 2 Exercise Sets 1, 2, 3, 4 (all parts) Analysis Questions 1, 2, 3, 5, 7, 8 (all parts) Chapter 3 Exercise Sets 1.3, 1.4, 1.5, 1.6, 1.7, 1.8 Analysis Questions (none) Chapter 4 Exercise Sets 1.5, 1.7, 2.8, 2.9 Analysis Questions (none) Chapter 5 Not covered in AP Computer Science A Programming Projects "Fish" Project (handout) Labs None Supplemental Materials 23 Topic 21. After the AP Exam (duration varies) Suggested Activities: • Learn the mobile edition of Java and program cell phones • Study text chapter 20 (data structures) and 21 (advanced data structures) • Study text chapter 22 (generic programming) • Study an example of a non-trivial computer game 24 AP Computer Science A Topic Outline (Syllabus Topics Cross Reference) I. Object-Oriented Program Design A. Program Design 1. Read and understand a problem's description, purpose, and goals. (3, 9) 2. Apply data abstraction and encapsulation. (3, 9) 3. Read and understand class specifications and relationships among classes ("is-a", "has-a" relationships). (9, 17) 4. Understand and implement a given class hierarchy. (17) 5. Identify reusable components from existing code using classes and class libraries. (13, 17) B. Class Design 1. Design and implement a class. (3, 9) 2. Design an interface. (11) 3. Choose appropriate data representation and algorithms. (8, 19, 20) 4. Apply functional decomposition. (2) 5. Extend a given class using inheritance. (13) II. Program Implementation A. Implementation Techniques 1. Methodology a. Object-oriented development (2, 3, 9, 17) b. Top-down development (3, 9) c. Encapsulation and information hiding (3, 9) d. Procedural abstraction (3) B. Programming constructs 1. Primitive types vs. objects (2) 2. Declaration a. Constant declarations (2, 4) b. Variable declarations (2) c. Class declarations (3) d. Interface declarations (11) e. Method declarations (2, 3) f. Parameter declarations (3) 3. Console output (1, 3) 4. Control a. Methods (3) b. Sequential (4) c. Conditional (6) d. Iteration (7) e. Recursion (18) C. Java library classes (1, 2) 25 III. Program Analysis A. Testing 1. Test classes and libraries in isolation. (3, 10) 2. Identify boundary cases and generate appropriate test data. (10) 3. Perform integration testing. (10) B. Debugging 1. Categorize errors; compile-time, run-time, logic (1) 2. Identify and correct errors (1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 17) 3. Techniques; use a debugger, add extra output statements, hand-trace code (10) C. Understand and modify existing code (17, Case Study) D. Extend existing code using inheritance (13, Case Study) E. Understand error handling 1. Understand runtime exceptions (15) F. Reason about programs 1. Pre-and post-conditions (9) 2. Assertions (9) G. Analysis of algorithms 1. Informal comparisons of running times (19) 2. Exact calculation of statement execution counts (7, 19) H. Numerical representations and limits 1. Representations of numbers in different bases (1, 4) 2. Limitations of finite representations (4) IV. Standard Data Structures A Simple data types (int, boolean, double) (2, 4) B. Classes (3, 9, 13) C. One-dimensional arrays (8) V. Standard Algorithms A. Operations on data structures 1. Traversals (8) 2. Insertions (8) 3. Deletions (8) B. Searching 1. Sequential (19) 2. Binary (19) C. Sorting 1. Selection (19) 2. Insertion (19) 3. Mergesort (19) 26 VI. Computing in Context A. Major hardware components 1. Primary and secondary memory (1) 2. Processors (1) 3. Peripherals (1) B. System software 1. Language translators/compilers (1) 2. Virtual machines (1) 3. Operating systems (1) C. Types of systems 1. Single-user systems (1) 2. Networks (1) D. Responsible use of computer systems 1. System reliability (1, 10) 2. Privacy (13) 3. Legal issues and intellectual property (1) 4. Social and ethical ramifications of computer use (1, supplemental readings) 27