Randolph Township Schools Randolph High School AP Computer Science A Curriculum

“Mathematics provides a framework for dealing precisely with notions of ‘what is’. Computation provides a framework for dealing precisely with notions of ‘how to’”.

- Harold Abelson and Gerald Jay Sussman with Julie Sussman

STEM+B Anthony Emmons, Supervisor

Curriculum Committee Matthew Horner Timothy McElroy

Curriculum Developed: June, 2020

Date of Board Approval: September 15th, 2020

1

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Table of Contents

Mission Statement ...... 3 Affirmative Action Statement ...... 3 EDUCATIONAL GOALS ...... 4 Introduction ...... 5 Curriculum Pacing Chart ...... 6 Unit I: Primitive Types ...... 7 Unit II: Using Objects ...... 12 Unit III: Boolean Expressions and if Statements ...... 19 Unit IV: Iteration ...... 23 Unit V: Writing Classes ...... 28 Unit : Arrays ...... 38 Unit VII: ArrayLists ...... 43 Unit VIII: Two-Dimensional Arrays ...... 48 Unit IX: Inheritance ...... 51 Unit X: Recursion ...... 56 Unit XI: Extra Post-AP Exam Projects ...... 59 APPENDIX A ...... 63 APPENDIX B ...... 64 APPENDIX ...... 65

2

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Mission Statement

We commit to inspiring and empowering all students in Randolph schools to reach their full potential as unique, responsible and educated members of a global society.

Affirmative Action Statement Equality and Equity in Curriculum The Randolph Township School district ensures that the district’s curriculum and instruction are aligned to the state’s standards. The curriculum provides equity in instruction, educational programs and provides all students the opportunity to interact positively with others regardless of race, creed, color, national origin, ancestry, age, marital status, affectional or sexual orientation, gender, religion, disability or socioeconomic status.

N.J.A.C. 6A:7-1.7(b): Section 504, Rehabilitation Act of 1973; N.J.S.A. 10:5; Title IX, Education Amendments of 1972

3

Randolph Township Schools Randolph High School AP Computer Science A Curriculum

EDUCATIONAL GOALS VALUES IN EDUCATION

The statements represent the beliefs and values regarding our educational system. Education is the key to self-actualization, which is realized through achievement and self-respect. We believe our entire system must not only represent these values, but also demonstrate them in all that we do as a school system.

We believe: • The needs of the child come first • Mutual respect and trust are the cornerstones of a learning community • The learning community consists of students, educators, parents, administrators, educational support personnel, the community and Board of Education members • A successful learning community communicates honestly and openly in a non-threatening environment • Members of our learning community have different needs at different times. There is openness to the challenge of meeting those needs in professional and supportive ways • Assessment of professionals (i.e., educators, administrators and educational support personnel) is a dynamic process that requires review and revision based on evolving research, practices and experiences • Development of desired capabilities comes in stages and is achieved through hard work, reflection and ongoing growth

4

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Introduction

AP Computer Science A is an elective course, offered to juniors and seniors who have completed an honors-level course in Python/. The course introduces students to computer science with fundamental topics that include problem solving, design strategies and methodologies, organization of data (data structures), approaches to processing data (algorithms), analysis of potential solutions, and the ethical and social implications of computing. The course emphasizes both object-oriented and imperative problem solving and design. These techniques represent proven approaches for developing solutions that can scale up from small, simple problems to large, complex problems.

The AP Computer Science A course curriculum is compatible with many introductory computer science courses in colleges and universities. Students who successfully complete the AP Computer Science A examination may receive credit for one semester of college computer science. Students are strongly encouraged to take the AP exam.

5

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Curriculum Pacing Chart

SUGGESTED TIME UNIT NUMBER CONTENT - UNIT OF STUDY ALLOTMENT 3 weeks I Primitive Types 4 weeks II Using Objects 3 weeks III Boolean Expressions and if Statements 4 weeks IV Iteration 4 weeks V Writing Classes 3 weeks VI Arrays 3 weeks VII Array Lists 2 weeks VIII Two-Dimensional Arrays 3 weeks IX Inheritance 2 weeks X Recursion 5 weeks XI Extra Post-AP Exam Projects

6

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit I: Primitive Types

TRANSFER: Manipulate variables and data for use in programming.

STANDARDS / GOALS: ENDURING UNDERSTANDINGS ESSENTIAL QUESTIONS

8.1.12.CS.1: Describe ways in which Java is built with several existing datatypes • How can a program return integrated systems hide underlying for common programming needs. information to the user? implementation details to simplify user • When are existing datatypes experiences. sufficient vs. efficient for a ’s needs? 8.1.12.CS.2: Model interactions between application software, system software, and Variables exist as named memory locations • When should a programmer allocate hardware. for storing data. memory to store a value?

• 8.1.12.CS.3: Compare the functions of What tradeoffs exist between a application software, system software, and variable name’s concision and hardware. descriptiveness?

8.1.12.AP.1: Design algorithms to solve The type of data an operator may manipulate • How are numerical operations in computational problems using a combination depends on how the operator is defined to be programming different from math of original and existing algorithms. used. class?

8.1.12.AP.2: Create generalized KNOWLEDGE SKILLS computational solutions using collections Students will know: Students will be able to: instead of repeatedly using simple variables. Printing statements are used to display Utilize System.out.println to move the cursor information to the computer monitor. to a new line after the information has been displayed, and System.out.print to remain on the same line.

7

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit I: Primitive Types

8.1.12.AP.6: Create artifacts by using Data types are defined by their values and the Categorize data types as either primitive or procedures within a program, combinations operations that may be performed on those reference. of data and procedures, or independent but values. interrelated programs. Identify the three primitive data types used in this course: int, double, and Boolean. 8.1.12.AP.7: Collaboratively design and Variables are names given to locations in Recall that each variable has associated develop programs and artifacts for broad computer memory. memory that is used to hold its value. audiences by incorporating feedback from users. Recognize that memory associated with a variable of a primitive type holds an actual 8.1.12.AP.8: Evaluate and refine primitive value. computational artifacts to make them more usable and accessible. Explain that when a variable is declared ‘final’, its value cannot be changed once it is 8.1.12.AP.9: Collaboratively document and initialized. present design decisions in the development Programming languages incorporate familiar Define a literal as the source code of complex programs. mathematical arithmetic operations. representation of a fixed value.

Recall that arithmetic operations include expressions of type int and double. Utilize arithmetic operators consisting of +, −, *, /, and %. Recognize that an arithmetic operation that uses two int values will evaluate to an int value, and arithmetic operations that use a double value will evaluate to a double value.

8

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit I: Primitive Types

Compound expressions in programming Explain that operators can be used to languages incorporate more than one construct compound expressions. operation. Recall that during evaluation, operands are associated with operators according to operator precedence to determine how they are grouped. Evoke arithmetic exceptions by dividing by zero. Expressions produce singular values to be Utilize the assignment operator (=) to used in computer programs. initialize or change the value stored in a variable by placing what is on the right into what is on the left. Relate that the value of an expression has a type based on the evaluation of the expression. Several shorthand operators are built into Discover that compound assignment programming languages to save time on operators (+=, −=, *=, /=, %=) can be used in common operations. place of the assignment operator. Utilize increment operator (++) and decrement operator (−−) to add 1 or subtract 1 from the stored value of a variable or an array element.

9

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit I: Primitive Types

Operations within computer programs Create a temporary value by using casting produce results based on the operation and operators (int) and (double) to convert to a operands, as opposed to conventional different data type. mathematical thinking. Describe why casting a double value to an int causes the digits to the right of the decimal point to be truncated. Recognize when some programming code causes int values to be automatically cast (widened) to double values. Round double values to the nearest integer by (int)(x + 0.5) for positive numbers, or (int)(x – 0.5) for negative numbers. Recall that integer values in Java are represented by values of type int, which are stored using a finite amount (4 bytes) of memory. Therefore, an int value must be in the range from Integer.MIN_VALUE to Integer.MAX_ VALUE inclusive. Recognize that if an expression would evaluate to an int value outside of the allowed range, an integer overflow occurs, and that this could result in an incorrect value within the allowed range.

10

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit I: Primitive Types

KEY TERMS: type, primitive, reference, int, double, boolean, variable, operator, String, final, expression

ASSESSMENT EVIDENCE: Students will show their learning by: • Developing a program to collect and calculate statistics of movie ratings. • Designing a program to determine the date and time given the number of seconds beyond a starting date and time. KEY LEARNING EVENTS AND INSTRUCTION: • Students download and install the IDE of their choice, with DrJava as the recommendation. • Students run their first simple “Hello World!” program. • Students identify similarities and additions to familiar PEMDAS precedence from math class to Java. SUGGESTED TIME ALLOTMENT 3 weeks SUPPLEMENTAL UNIT RESOURCES Edhesive.com – AP Computer Science A course

https://apcentral.collegeboard.org/courses/ap-computer-science-a/classroom-resources/lab- resource-page?course=ap-computer-science-a – College Board AP CSA Resources

DrJava.org – DrJava IDE

https://docs.oracle.com/javase/tutorial/ – Oracle Java Tutorials

https://introcs.cs.princeton.edu/java/11precedence/ – Java precedence table

11

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit II: Using Objects

TRANSFER: Incorporate Strings and other object-bound data as a feedback mechanism for computer and users.

STANDARDS / GOALS: ENDURING UNDERSTANDINGS ESSENTIAL QUESTIONS

8.1.12.CS.1: Describe ways in which Classes are written to be used by other • When are existing data types integrated systems hide underlying classes in object-oriented programming. insufficient vs. inefficient for a implementation details to simplify user programmer’s needs? experiences. • How does the need for a class inform its design? 8.1.12.CS.2: Model interactions between application software, system software, and Existing Java classes incorporate tested code • Why is it important to reuse existing hardware. for common programming needs. Java code?

8.1.12.CS.3: Compare the functions of Methods can be written to perform • application software, system software, and When and should a programmer write algorithms robust to a variety of input. hardware. a method? • How can programmers design 8.1.12.AP.1: Design algorithms to solve methods to respond to different input computational problems using a combination than they originally intended? of original and existing algorithms. Strings are an important tool for translating • How do Strings help programmers 8.1.12.AP.2: Create generalized natural language to programming input and receive feedback from and give input computational solutions using collections output. to computers? instead of repeatedly using simple variables. • How can programmers combine Strings with other data types? 8.1.12.AP.3: Select and combine control structures for a specific application based upon performance and readability, and identify trade-offs to justify the choice.

12

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit II: Using Objects

8.1.12.AP.4: Design and iteratively develop KNOWLEDGE SKILLS computational artifacts for practical intent, Students will know: Students will be able to: personal expression, or to address a societal Objects and classes are related, but non- Classify an object as a specific instance of a issue. interchangeable concepts. class with defined attributes.

8.1.12.AP.5: Decompose problems into Define a class as the formal implementation, smaller components through systematic or blueprint, of the attributes and behaviors analysis, using constructs such as procedures, of an object. modules, and/or objects. Methods outline the data they are sent Differentiate methods by the name and the through their signatures. parameter list. 8.1.12.AP.6: Create artifacts by using procedures within a program, combinations Outline data to be sent to a method, in the of data and procedures, or independent but header of a method, through a list of formal interrelated programs. parameters.

8.1.12.AP.7: Collaboratively design and Overload methods by defining them with the develop programs and artifacts for broad same name but a different signature. audiences by incorporating feedback from Constructors are used to instantiate objects. Pass data to a constructor, in the form of users. actual parameters, by value.

8.1.12.AP.8: Evaluate and refine Create objects using the keyword ‘new’ computational artifacts to make them more followed by a call to one of the class’s usable and accessible. constructors.

8.1.12.AP.9: Collaboratively document and Utilize existing classes and class libraries as present design decisions in the development appropriate to instantiate objects. of complex programs.

13

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit II: Using Objects

The memory associated with a variable of a Define variables of the correct types to reference type holds the memory address of represent reference data. the referenced object. Indicate that a reference is not associated with an object using the ‘null’ special value. Void methods do not return values. Define an object’s behavior through writing methods. Use a method knowing what the method does, but not how it was written, through procedural abstraction. Outline the sequential execution of program statements when interrupted by a method call. Call non-static methods through objects of a class using the dot operator and object name. Execute void methods independently of other expressions. Evoke NullPointerExceptions through method calls with null object references. Use compile-time errors to debug incorrect method calls.

14

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit II: Using Objects

Non-void methods return a value that is the Call non-static, non-void methods with or same type as the return type in the signature. without parameters.

Use the return value when calling a non-void method by storing it in a variable or including it as part of an expression. Immutable String objects can be created by Concatenate String objects using the + or += using String literals or by calling the String operator, resulting in a new String object. class constructor. Implicitly-convert primitive values to String objects through concatenation. Incorporate escape sequences within String objects, including \”, \\, and \n. The String class provides a variety of built-in Review the String Application Programming methods for common processing needs. Interface (API) to its available instance methods. Outline String character indices from 0 to length – 1. Use StringIndexOutOfBoundsException through references to out-of-range indices. Implicitly call a referenced object to String method through concatenation with an existing String.

15

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit II: Using Objects

String instance methods must be called using Characterize and use the following String an existing String object. methods in the appropriate context: - String (String) - int length() - String subString(int, int) - String subString(int) - int indexOf(String) - boolean equals(String) - int compareTo(String) Wrapper classes can be thought of as Use the following wrapper class methods and reference-type versions of primitive types. variables in the appropriate context: - Integer(int) - Integer.MIN_VALUE - Integer.MAX_VALUE - int intValue() - Double(double) - double doubleValue() Autobox primitive types for implicit conversion to the associated wrapper class by: - Passing a primitive type as a parameter to a method that expects an object of the corresponding wrapper class. - Assigning a primitive type to a variable of the corresponding wrapper class.

16

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit II: Using Objects

Unboxing may be thought of as the reverse Unbox wrapper classes for implicit of the autoboxing process. conversion to the associated primitive type by: - Passing the object as a parameter to a method that expects a value of the corresponding primitive type. - Assigning the object to a variable of the corresponding primitive type. Static methods are associated with the class Call static methods using the dot operator in which they are created, rather than a along with the class name, except when the specific instance of that class. method is defined in the enclosing class. The Math class exclusively includes static Use the following static Math methods in the methods that can be used to perform more appropriate context: advanced common mathematical operations - int abs(int) than those of standard operators. - double abs(double) - double pow(double, double) - double sqrt(double) - double random() Manipulate the values returned from Math.random to produce a random int or double in a defined range.

KEY TERMS: object, class, instance, parameter, signature, method, constructor, primitive, reference, void, return, null, static, dot operator, immutable, escape sequence, API, wrapper class, autoboxing, unboxing

17

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit II: Using Objects

ASSESSMENT EVIDENCE: Students will show their learning by: • Developing a program to remove characters from Strings based on predefined rules. KEY LEARNING EVENTS AND INSTRUCTION: • Students look at their first Java API pages for String, Math, and Wrapper classes. • Students explore an old practice exam question on random number generation and explain why EVERY answer is incorrect. • Students write their first methods to fulfill algorithmic procedures through interruption of, rather than sequential execution of, the main method code. SUGGESTED TIME ALLOTMENT 4 weeks SUPPLEMENTAL UNIT RESOURCES Edhesive.com – AP Computer Science A course

https://apcentral.collegeboard.org/courses/ap-computer-science-a/classroom-resources/lab- resource-page?course=ap-computer-science-a – College Board AP CSA Resources

DrJava.org – DrJava IDE

https://codingbat.com/java – Coding Bat practice problems

https://docs.oracle.com/javase/7/docs/api/java/lang/String.html – Java String API

https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html – Java Math API

https://www.w3schools.com/java/java_wrapper_classes.asp – W3 Understanding Wrapper Classes

https://www.w3schools.com/java/java_oop.asp – W3 Understanding Objects

18

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit III: Boolean Expressions and if Statements

TRANSFER: Write conditional statements to allow computers to make decisions.

STANDARDS / GOALS: ENDURING UNDERSTANDINGS ESSENTIAL QUESTIONS

8.1.12.CS.1: Describe ways in which Sequencing considerations present for • When can seemingly-equivalent integrated systems hide underlying arithmetic expressions are also imperative for Boolean expressions yield differing implementation details to simplify user accurate prediction of the results of Boolean results? experiences. expressions. • How can precedence and associativity rules for arithmetic expressions be 8.1.12.CS.2: Model interactions between compared and contrasted to those for application software, system software, and Boolean expressions? hardware. Conditional statements allow computer • How do computers make decisions? 8.1.12.AP.1: Design algorithms to solve programs to make decisions based on varied • How can programmers write computational problems using a combination input. conditional statements to be robust to of original and existing algorithms. varied input?

8.1.12.AP.2: Create generalized Object equivalence from a computer’s • What does it mean for two objects to computational solutions using collections perspective is associated with memory be equal to one another? instead of repeatedly using simple variables. addresses, while equivalence from a human perspective is defined by the programmer. 8.1.12.AP.3: Select and combine control KNOWLEDGE SKILLS structures for a specific application based Students will know: Students will be able to: upon performance and readability, and Relational operators evaluate to Boolean Compare primitive values and reference identify trade-offs to justify the choice. values in programming. values using relational operators (i.e., == and

!=).

Compare arithmetic expression values using relational operators (i.e., <, >, <=, >=).

19

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit III: Boolean Expressions and if Statements

8.1.12.AP.4: Design and iteratively develop Branching logical processes are constructed Demonstrate that conditional statements computational artifacts for practical intent, through conditional statements. interrupt the sequential execution of personal expression, or to address a societal statements. issue. Utilize the value of a Boolean expression of 8.1.12.AP.5: Decompose problems into if statements to control the flow of a program smaller components through systematic by executing different statements. analysis, using constructs such as procedures, Define a one-way selection (if statement) as modules, and/or objects. a set of statements set to execute only when the Boolean condition is true. 8.1.12.AP.6: Create artifacts by using procedures within a program, combinations Define a two-way selection as two sets of of data and procedures, or independent but statements—one to be executed when the interrelated programs. Boolean condition is true, and another set for when the Boolean condition is false. 8.1.12.AP.7: Collaboratively design and develop programs and artifacts for broad Define a multi-way selection when using if- audiences by incorporating feedback from else-if statements such that exactly one users. section of code is executed based on the first condition that evaluates to true. 8.1.12.AP.8: Evaluate and refine Define nested if statements that consist of if computational artifacts to make them more statements within if statements. usable and accessible. Translate nested if statements into equivalent 8.1.12.AP.9: Collaboratively document and if-else-if statements. present design decisions in the development of complex programs.

20

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit III: Boolean Expressions and if Statements

Multiple conditions may be evaluated in Utilize logical operators ! (not), && (and), Boolean expressions using logical operators. and || (or) to produce Boolean values. This represents the order these operators will be evaluated. Define a short-circuited evaluation as one that contains a logical expression using && or || and evaluates only the first Boolean operand but not the second. Equivalent Boolean expressions may be Apply De Morgan’s Laws to Boolean written in multiple ways. expressions. Prove Boolean identities using truth tables. Recognize that equivalent Boolean expressions will evaluate to the same value in all cases. Object reference equality and programmer- Define aliases as two references that both defined object equality are separate reference the same object. considerations. Compare reference values using == and !=, to identify aliases. Compare a reference with null, using == or !=, to determine if the reference is actually an object. Use a class’s own equals method to determine whether two objects of the class are equivalent.

21

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit III: Boolean Expressions and if Statements

KEY TERMS: primitive values, reference values, relational operators, logical operators, one-way selection, two-way selection, multi- way selection, nested conditional, null, classes, Boolean, truth table, short-circuit, De Morgan’s Law, aliases

ASSESSMENT EVIDENCE: Students will show their learning by: • Creating a “safe-cracker” program to respond to and evaluate user input for correctness. KEY LEARNING EVENTS AND INSTRUCTION: • Students write complex conditionals with the same output, but different solely-if, else-if, and else structures. • Students construct and evaluate truth tables for complex conditionals output and simplification. SUGGESTED TIME ALLOTMENT 3 weeks SUPPLEMENTAL UNIT RESOURCES Edhesive.com – AP Computer Science A course

https://apcentral.collegeboard.org/courses/ap-computer-science-a/classroom-resources/lab- resource-page?course=ap-computer-science-a – College Board AP CSA Resources

DrJava.org – DrJava IDE

https://codingbat.com/java - Coding Bat practice problems

https://docs.oracle.com/javase/tutorial/ - Oracle Java Tutorials

https://library.alliant.edu/screens/boolean.pdf - What are Boolean Operators

22

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit IV: Iteration

TRANSFER: Use computers to iteratively complete tasks a number of times unrealistic for human capabilities.

STANDARDS / GOALS: ENDURING UNDERSTANDINGS ESSENTIAL QUESTIONS

8.1.12.CS.1: Describe ways in which Both while and for loops are used to concisely • When are while loops preferable to for integrated systems hide underlying repeat sections of program code. loops, and vice-versa? implementation details to simplify user • When is a loop appropriate over hard- experiences. coding repeated instructions?

8.1.12.CS.2: Model interactions between Execution of iterative statements is • What options are available to application software, system software, and dependent on the evaluation of associated programmers for ending iteration hardware. Boolean expressions. within code?

8.1.12.AP.1: Design algorithms to solve There exist tried-and-true standard • computational problems using a combination How do standard algorithms depend algorithms for processes common to program of original and existing algorithms, on iteration and/or selection to code. function? 8.1.12.AP.2: Create generalized • When should a standard algorithm be computational solutions using collections modified to fit a programmer’s need, instead of repeatedly using simple variables. as opposed to developing a new algorithm entirely? 8.1.12.AP.3: Select and combine control structures for a specific application based KNOWLEDGE SKILLS upon performance and readability, and Students will know: Students will be able to: identify trade-offs to justify the choice. While loops should be used to repeat Develop iteration statements to change the statements an unknown number of times. flow of control by repeating a set of statements zero or more times until a condition is met.

23

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit IV: Iteration

8.1.12.AP.4: Design and iteratively develop In loops, the Boolean expression is evaluated Determine that a loop is an infinite loop computational artifacts for practical intent, before each iteration of the loop body, when the Boolean expression always personal expression, or to address a societal including the first. When the expression evaluates to true. issue. evaluates to true, the loop body is executed. This continues until the expression evaluates Explain that if the Boolean expression 8.1.12.AP.5: Decompose problems into to false, whereupon the iteration ceases. evaluates to false initially, the loop body is smaller components through systematic not executed at all. analysis, using constructs such as procedures, Execute a return statement inside an iteration modules, and/or objects. statement to halt the loop and exit the method or constructor. 8.1.12.AP.6: Create artifacts by using procedures within a program, combinations Standard algorithms exist for numeric Use standard algorithms to: of data and procedures, or independent but processes but may be modified to fit - Identify if an integer is or is not interrelated programs. particular situations. evenly divisible by another integer. - Identify the individual digits in an 8.1.12.AP.7: Collaboratively design and integer. develop programs and artifacts for broad - Determine the frequency with which audiences by incorporating feedback from a specific criterion is met. users. Use standard algorithms to: 8.1.12.AP.8: Evaluate and refine - Determine a minimum or maximum computational artifacts to make them more value. usable and accessible. - Compute a sum, average, or mode. Incorporate standard algorithms into program 8.1.12.AP.9: Collaboratively document and code to achieve a desired or unique result. present design decisions in the development of complex programs.

24

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit IV: Iteration

For loops should be used to repeat statements Define three parts in a for loop header: the a known number of times. initialization, the Boolean expression, and the increment, recognizing that the increment statement can also be a decrement statement. Develop in a for loop, the initialization statement to execute once before the first Boolean expression evaluation. Define the variable being initialized as a loop control variable. Recognize in each iteration of a for loop, the increment statement is executed after the entire loop body is executed and before the Boolean expression is evaluated again. Rewrite a for loop into an equivalent while loop and vice versa. Determine that “off by one” errors occur when the iteration statement loops one time too many or one time too few. Looping behavior is the basis for several Utilize String traversals to: common word processor algorithms. - Find if one or more subStrings has a particular property. - Determine the number of subStrings that meet specific criteria. - Create a new String with the characters reversed.

25

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit IV: Iteration

Nested loops multiplicatively-increase the Utilize nested iteration statements that appear total number of programmatic iterations. in the body of another iteration statement. Distinguish that when a loop is nested inside another loop, the inner loop must complete all its iterations before the outer loop can continue. Counting loops may be useful for algorithmic Write a statement execution count indicating output as well as debugging. the number of times a statement is executed by the program.

KEY TERMS: iteration, for loops, while loops, counting loop, nested loop, “off-by- one”

ASSESSMENT EVIDENCE: Students will show their learning by: • Defining and implementing String and number processing techniques in the context of Java methods. • Utilizing iteration techniques to repeat otherwise-tedious processes. KEY LEARNING EVENTS AND INSTRUCTION: • Students translate while loop code into equivalent for loop code, and vice-versa. • Students trace code on pen and paper for complex loops, including nesting.

26

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit IV: Iteration

SUGGESTED TIME ALLOTMENT 4 weeks SUPPLEMENTAL UNIT RESOURCES Edhesive.com – AP Computer Science A course

https://apcentral.collegeboard.org/courses/ap-computer-science-a/classroom-resources/lab- resource-page?course=ap-computer-science-a – College Board AP CSA Resources

DrJava.org – DrJava IDE

https://codingbat.com/java – Coding Bat practice problems

https://docs.oracle.com/javase/tutorial/ – Oracle Java Tutorials

https://teachcomputerscience.com/iterations/ – Understanding Iteration

27

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit V: Writing Classes

TRANSFER: Generate novel datatype blueprints through creation of novel Java classes.

STANDARDS / GOALS: ENDURING UNDERSTANDINGS ESSENTIAL QUESTIONS

8.1.12.CS.1: Describe ways in which Programmers use code to represent a • When are existing data types integrated systems hide underlying physical object or nonphysical concept, real insufficient vs. inefficient for a implementation details to simplify user or imagined, by defining a class based on the programmer’s needs? experiences. attributes and/or behaviors of the object or • How does the need for a class inform concept. its design? 8.1.12.CS.2: Model interactions between • When should variables and methods application software, system software, and be associated with all instances of a hardware. class vs. specific to individual

instances? 8.1.12.AP.1: Design algorithms to solve computational problems using a combination Encapsulation is one of the core principles of • of original and existing algorithms. Why is it important to restrict access an object-oriented programming model and to a portion of an object’s involves restrictions on access to an object’s 8.1.12.AP.2: Create generalized components? components. • computational solutions using collections How can methods be used to instead of repeatedly using simple variables. conditionally allow access to an object’s components? 8.1.12.AP.3: Select and combine control structures for a specific application based While programs are typically designed to • What ethical and social issues are upon performance and readability, and achieve a specific purpose, they may have present when writing program code? identify trade-offs to justify the choice. unintended consequences. • How can comments increase code transparency?

28

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit V: Writing Classes

8.1.12.AP.4: Design and iteratively develop KNOWLEDGE SKILLS computational artifacts for practical intent, Students will know: Students will be able to: personal expression, or to address a societal The “public” and “private” keywords are Determine that the keywords public and issue. used to designate accessibility of methods private affect the access of classes, data, and data within a class. constructors, and methods. 8.1.12.AP.5: Decompose problems into Use the keyword private to restrict access to smaller components through systematic the declaring class and use the keyword analysis, using constructs such as procedures, public to allow access from classes outside modules, and/or objects. the declaring class.

8.1.12.AP.6: Create artifacts by using Explain why classes are designated as public. procedures within a program, combinations of data and procedures, or independent but Designate instance variables as private to interrelated programs. keep access attributes internal to the class.

Explain why constructors are designated as 8.1.12.AP.7: Collaboratively design and public. develop programs and artifacts for broad audiences by incorporating feedback from Designate methods as either public or private users. to allow access to behaviors internally or externally. 8.1.12.AP.8: Evaluate and refine computational artifacts to make them more Encapsulation is the principle of restricting Use data encapsulation techniques to keep usable and accessible. direct access to some of an object’s details of a class hidden from the user. components. Design a class through decision-making 8.1.12.AP.9: Collaboratively document and about what data to make accessible and present design decisions in the development modifiable from an external class. of complex programs.

29

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit V: Writing Classes

Data can be either accessible or modifiable, Use private access modifiers to encapsulate or it can be both or neither. instance variables. Write the provided accessor and mutator methods in a class to allow client code to use and modify data. The state of an object is defined through its Create “has-a” relationships between objects instance variables. and their instance variables. Write constructors to set the initial state of an object, which should include initial values for all instance variables. Determine constructor parameters as local variables to the constructor and provide data to initialize instance variables. Recognize that when a mutable object is a constructor parameter, the instance variable should be initialized with a copy of the referenced object. In this way, the instance variable is not an alias of the original object, and methods are prevented from modifying the state of the original object. Distinguish that when no constructor is written, Java provides a no-argument constructor, and the instance variables are set to default values.

30

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit V: Writing Classes

Comments are written exclusively for the Recognize that comments are ignored by the programmers. compiler and are not executed when the program is run. Define three types of comments in Java as /* */, which generates a block of comments, //, which generates a comment on one line, and /** */, which are Javadoc comments and are used to create API documentation. Use a precondition that must be true just prior to the execution of a section of program code in order for the method to behave as expected. There is no expectation that the method will check to ensure preconditions are satisfied. Use a postcondition that must always be true after the execution of a section of program code. Postconditions describe the outcome of the execution in terms of what is being returned or the state of an object. Write method code to satisfy the postconditions when preconditions are met.

31

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit V: Writing Classes

Non-void methods, or functions, return Utilize accessor methods to allow other singular values. objects to obtain the value of instance variables or static variables. Write non-void method headers to include the return type in place of the keyword void. Recognize in non-void methods, a return expression compatible with the return type is evaluated, and a copy of that value is returned. This is referred to as “return by value.” Recognize when the return expression is a reference to an object, a copy of that reference is returned, not a copy of the object. Use the return keyword to return the flow of control to the point immediately following where the method or constructor was called. The toString method generally includes what Use the toString method to override a values are stored in the instance data of the method that is included in classes to provide object. a description of a specific object. Utilize System.out.print or System.out. println to pass an object, and that object’s toString method is called, and the returned String is printed.

32

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit V: Writing Classes

Void methods, or procedures, do not return Write void method headers to contain the values. keyword void before the method name. Classify a mutator (modifier) method as, most often, a void method that changes the values of instance variables or static variables. Access to method parameter data is Recognize methods can only access the dependent on programmer encapsulation private data and methods of a parameter that design. is a reference to an object when the parameter is the same type as the method’s enclosing class. Use non-void methods to receive values through parameters and use those to return a computed value of the specified type. Changeability of method parameters is Write code to avoid modification of mutable dependent on whether the parameters are objects that are passed as parameters unless primitive or reference types, and the required in the specification. mutability of those that are reference types. Recognize that when an actual parameter is a primitive value, the formal parameter is initialized with a copy of that value. Changes to the formal parameter have no effect on the corresponding actual parameter.

33

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit V: Writing Classes

Methods and constructors can alter the state Determine that when an actual parameter is a of referenced mutable objects. reference to an object, the formal parameter is initialized with a copy of that reference, not a copy of the object. Passing a reference parameter results in the formal parameter and the actual parameter being aliases. They both refer to the same object. Static methods are associated with a class, as Define static methods with the classes, not opposed to specific individual instances of objects of the class. the class. Use the keyword static in the header before the method name. Verify that static methods cannot access or change the values of instance variables. Verify that static methods can access and change the values of static variables. Verify that static methods do not have “this” reference and are unable to use the class’s instance variables or call non-static methods.

34

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit V: Writing Classes

Static variables define attributes associated Designate static variables as either public or with all instances of a class. private and include the static keyword before the variable type. Use static variables with the class name and the dot operator, since they are associated with a class, not objects of a class. Variables may only be referenced within Declare local variables in the body of their declared scope. constructors and methods. These variables may only be used within the constructor or method and cannot be declared to be public or private. Recognize when there is a local variable with the same name as an instance variable, the variable name will refer to the local variable instead of the instance variable. Determine that formal parameters and variables declared in a method or constructor can only be used within that method or constructor. Revise through method decomposition, breaking down a large problem into smaller subproblems by creating methods to solve each individual subproblem.

35

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit V: Writing Classes

The “this” keyword may be used to reference Use within a non-static method or a the implicitly available current object. constructor, the keyword “this” is a reference to the current object—the object whose method or constructor is being called. Use keyword “this” to pass the current object as an actual parameter in a method call. Programmers must consider the ethical and Write code to maximize system reliability. social implications of the code they write. Define legal issues and intellectual property concerns that could arise when creating programs. Recognize the creation of programs has impacts on society, economies, and culture. These impacts can be beneficial and/or harmful.

KEY TERMS: classes, data, constructors, methods, accessors, mutators, private, public, this, toString, static, non-static, header, include, comments, this, local, global, scope

36

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit V: Writing Classes

ASSESSMENT EVIDENCE: Students will show their learning by: • Developing a Java class to represent a mathematical Fraction. KEY LEARNING EVENTS AND INSTRUCTION: • Students write their first class to represent a new data type, as opposed to thinking of it as nothing more than a file name. • Students implement methods for class behavior and instance variables for attributes, all outside of a main method. SUGGESTED TIME ALLOTMENT 4 weeks SUPPLEMENTAL UNIT RESOURCES Edhesive.com – AP Computer Science A course

https://apcentral.collegeboard.org/courses/ap-computer-science-a/classroom-resources/lab- resource-page?course=ap-computer-science-a – College Board AP CSA Resources

DrJava.org – DrJava IDE

https://codingbat.com/java – Coding Bat practice problems

https://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html – Oracle Java Tutorial on Public and Private Classes

37

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit VI: Arrays

TRANSFER: Design program code with an eye on efficiency through use of data structures, as opposed to variables with individualized information.

STANDARDS / GOALS: ENDURING UNDERSTANDINGS ESSENTIAL QUESTIONS

8.1.12.CS.1: Describe ways in which To manage large amounts of data or complex • When should an array be used over integrated systems hide underlying relationships in data, programmers write multiple closely-related variables? implementation details to simplify user code that groups the data together into a • When should an array be used over an experiences. single data structure without creating ArrayList? individual variables for each value. 8.1.12.CS.2: Model interactions between application software, system software, and Data structures are often insufficient for • Why are for loops so commonly hardware. more-simply managing large datasets or associated with arrays, as opposed to complex relationships without associated while loops? 8.1.12.AP.1: Design algorithms to solve iterative algorithms. • How does iteration enhance the computational problems using a combination efficiency of using an array? of original and existing algorithms

There exist tried-and-true standard • How do standard algorithms depend 8.1.12.AP.2: Create generalized algorithms for processes common to program on iteration and/or selection to computational solutions using collections code. function? instead of repeatedly using simple variables. • When should a standard algorithm be 8.1.12.AP.3: Select and combine control modified to fit a programmer’s need, structures for a specific application based as opposed to developing a new upon performance and readability, and algorithm entirely? identify trade-offs to justify the choice.

38

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit VI: Arrays

8.1.12.AP.4: Design and iteratively develop KNOWLEDGE SKILLS computational artifacts for practical intent, Students will know: Students will be able to: personal expression, or to address a societal Array objects allow multiple related items to Define the size of an array at the time of issue. be represented using a single variable. creation.

Recognize that arrays can store either 8.1.12.AP.5: Decompose problems into primitive data or object reference data. smaller components through systematic analysis, using constructs such as procedures, Distinguish that when an array is created modules, and/or objects. using the keyword “new”, all of its elements are initialized with a specific value based on 8.1.12.AP.6: Create artifacts by using the type of elements: procedures within a program, combinations - Elements of type int are initialized to of data and procedures, or independent but 0. interrelated programs. - Elements of type double are initialized to 0.0. 8.1.12.AP.7: Collaboratively design and - Elements of type boolean are develop programs and artifacts for broad initialized to false. audiences by incorporating feedback from - Elements of a reference type are users. initialized to the reference value null. No objects are automatically created. 8.1.12.AP.8: Evaluate and refine computational artifacts to make them more Use initializer lists to create and initialize usable and accessible. arrays.

Use square brackets ([ ]) to access and 8.1.12.AP.9: Collaboratively document and modify an element in a 1D array using an present design decisions in the development index. of complex programs.

39

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit VI: Arrays

Java, like many programming languages, is Recall that the valid index values for an array “zero-indexed”. are 0 through one less than the number of elements in the array, inclusive. Evoke an ArrayIndexOutOfBoundsException by using an index outside of this range. Iteration statements allow programmers to Write code to traverse an array using indices traverse arrays. with for loops and while loops to access array elements. Recognize “off-by-one” errors when traversing an array. Enhanced for loops may be used to simplify Use a variable in for loop header to create an program syntax, but come with limitations. enhanced for loop. Recognize that for each iteration of the enhanced for loop, the enhanced for loop variable is assigned a copy of an element without using its index. Determine that assigning a new value to the enhanced for loop variable does not change the value stored in the array. Rewrite program code written using an enhanced for loop to traverse and access elements in an array by using an indexed for loop or a while loop.

40

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit VI: Arrays

Standard algorithms exist array processing Use standard algorithms that utilize array techniques, but may be modified to fit traversals to: particular situations. - Determine a minimum or maximum value. - Compute a sum, average, or mode. - Determine if at least one element has a particular property. - Determine if all elements have a particular property. - Access all consecutive pairs of elements. - Determine the presence or absence of duplicate elements. - Determine the number of elements meeting specific criteria. - Shift or rotate elements left or right. - Reverse the order of the elements.

KEY TERMS: arrays, index, traverse, enhanced for loop

ASSESSMENT EVIDENCE: Students will show their learning by: • Designing a program to determine statistics of data organized in a one-dimensional array structure. • Creating a program to determine if one-dimensional arrays are sorted and merge them in sorted order. KEY LEARNING EVENTS AND INSTRUCTION: • Students will investigate, modify, and design components of a simple chatbot program. • Students make analogies of computer program array processing to statistics calculations in other classes.

41

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit VI: Arrays

SUGGESTED TIME ALLOTMENT 3 weeks SUPPLEMENTAL UNIT RESOURCES Edhesive.com – AP Computer Science A course

https://apcentral.collegeboard.org/courses/ap-computer-science-a/classroom-resources/lab- resource-page?course=ap-computer-science-a – College Board AP CSA Resources

DrJava.org – DrJava IDE

https://codingbat.com/java – Coding Bat practice problems

https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html – Oracle Tutorial on Arrays

https://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html – Java Arrays API

https://www.lynda.com/C-tutorials/Understanding-arrays/718661/771654-4.html – Lynda Understanding Arrays

42

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit VII: ArrayLists

TRANSFER: Compare and contrast the utility of object-bound list data structures with those used thus far.

STANDARDS / GOALS: ENDURING UNDERSTANDINGS ESSENTIAL QUESTIONS

8.1.12.CS.1: Describe ways in which To manage large amounts of data or complex • When should an ArrayList be used integrated systems hide underlying relationships in data, programmers write over multiple closely-related implementation details to simplify user code that groups the data together into a variables? experiences. single data structure without creating • When should an ArrayList be used individual variables for each value. over an array? 8.1.12.CS.2: Model interactions between application software, system software, and Data structures are often insufficient for • Why are while loops more often used hardware. more-simply managing large datasets or with ArrayLists than they are for

complex relationships without associated arrays? 8.1.12.AP.1: Design algorithms to solve iterative algorithms. • computational problems using a combination How does iteration enhance the of original and existing algorithms efficiency of using an ArrayList?

8.1.12.AP.2: Create generalized There exist tried-and-true standard • How do standard algorithms depend computational solutions using collections algorithms for processes common to program on iteration and/or selection to instead of repeatedly using simple variables. code. function? • When should a standard algorithm be 8.1.12.AP.3: Select and combine control modified to fit a programmer’s need, structures for a specific application based as opposed to developing a new upon performance and readability, and algorithm entirely? identify trade-offs to justify the choice.

43

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit VII: ArrayLists

8.1.12.AP.4: Design and iteratively develop KNOWLEDGE SKILLS computational artifacts for practical intent, Students will know: Students will be able to: personal expression, or to address a societal ArrayList objects are mutable and contain Construct an empty list using the constructor issue. object references. ArrayList().

Use ArrayList in Java, where the generic 8.1.12.AP.5: Decompose problems into type E specifies the type of the elements. smaller components through systematic analysis, using constructs such as procedures, Recognize when ArrayList is specified, modules, and/or objects. the types of the reference parameters and return type when using the methods are type 8.1.12.AP.6: Create artifacts by using E. procedures within a program, combinations of data and procedures, or independent but Prioritize ArrayList over ArrayList interrelated programs. because it allows the compiler to find errors that would otherwise be found at run-time. 8.1.12.AP.7: Collaboratively design and The ArrayList class provides a variety of Import the ArrayList class from the util develop programs and artifacts for broad built-in methods for common processing package. audiences by incorporating feedback from needs. users. Define the following ArrayList methods, including what they do and when they are 8.1.12.AP.8: Evaluate and refine used: computational artifacts to make them more - int size() usable and accessible. - boolean add(E) - void add(int, E) 8.1.12.AP.9: Collaboratively document and - boolean add(E) present design decisions in the development - E get(int) of complex programs. - E set(int, E) - E remove(int)

44

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit VII: ArrayLists

The ability to add and remove elements of Use iteration statements to access all ArrayLists requires care on the part of the elements in an ArrayList. This is called programmer to ensure iterative techniques traversing the ArrayList. function correctly. Use special techniques to avoid skipping elements when deleting elements during a traversal of an ArrayList. Recall that indices for an ArrayList start at 0 and end at the number of elements – 1. Accessing an index value outside of this range will result in an IndexOutOfBoundsException being thrown. When using an enhanced for loop to traverse Recognize that changing the size of an an ArrayList, it is not advisable to add or ArrayList while traversing it using an remove elements. enhanced for loop can result in a ConcurrentModificationException being thrown. We may liken standard algorithms for Use standard ArrayList algorithms when ArrayLists to those for arrays, with traversing an Array to: modifications. - Insert elements. - Delete elements. - Apply the same standard algorithms that are used with 1D arrays. Recognize that some algorithms require multiple String, array, or ArrayList objects to be traversed simultaneously.

45

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit VII: ArrayLists

Searching algorithms return the position of Use standard algorithms for searching. elements within a data structure. Recall that sequential/linear search algorithms check each element in order until the desired value is found or all elements in the array or ArrayList have been checked. Several standard sorting algorithms require Use Selection sort and Insertion sort to sort relatively little program code to implement. elements in an array or ArrayList. Tradeoffs between ease of programming and Use Informal run-time comparisons of run-time inform decision making when program code segments to make statement selecting standard algorithms. execution counts. Privacy concerns are paramount when Recognize that when using the computer, writing code. personal privacy is at risk. Write code attempting to safeguard personal privacy. Determine that computer use and the creation of programs have an impact on personal security. These impacts can be beneficial and/or harmful.

KEY TERMS: ArrayList, index, traverse, insertion sort, selection sort, linear search, run-time, privacy, security

46

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit VII: ArrayLists

ASSESSMENT EVIDENCE: Students will show their learning by: • Designing interacting Java classes to represent Boxcars and FreightTrains. • Implementing randomization into an existing casino wheel class. • Programming sorting behavior to a selection of TeamMember class instances based on instance variables. KEY LEARNING EVENTS AND INSTRUCTION: • Students compare and contrast the utility of arrays and ArrayLists in different situations. • Students incorporate a class they wrote into yet another new class for the first time. SUGGESTED TIME ALLOTMENT 3 weeks SUPPLEMENTAL UNIT RESOURCES Edhesive.com – AP Computer Science A course

https://apcentral.collegeboard.org/courses/ap-computer-science-a/classroom-resources/lab- resource-page?course=ap-computer-science-a – College Board AP CSA Resources

DrJava.org – DrJava IDE

https://codingbat.com/java – Coding Bat practice problems

https://docs.oracle.com/javase/8/docs/api/java/util/ArrayList.html – Java ArrayList API

https://www.geeksforgeeks.org/arraylist-in-java/ – Geek for Geeks ArrayList in Java

47

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit VIII: Two-Dimensional Arrays

TRANSFER: Create and process tabular data in multi-dimensional structured computer space.

STANDARDS / GOALS: ENDURING UNDERSTANDINGS ESSENTIAL QUESTIONS

8.1.12.CS.1: Describe ways in which 2D arrays may be thought of as 1D arrays of • What programmatic modifications integrated systems hide underlying 1D arrays. must be considered as arrays become implementation details to simplify user multi-dimensional? experiences. Data structures are often insufficient for • Why is nested iteration essential 8.1.12.CS.2: Model interactions between more-simply managing large datasets or when processing 2D arrays? application software, system software, and complex relationships without associated hardware. iterative algorithms.

8.1.12.AP.1: Design algorithms to solve KNOWLEDGE SKILLS computational problems using a combination Students will know: Students will be able to: of original and existing algorithms. Each individual row of a 2D array is a 1D Identify similarities in the way 2D and 1D array. arrays are created and indexed. 8.1.12.AP.2: Create generalized computational solutions using collections Recognize when accessing the element at instead of repeatedly using simple variables. arr[first][second], the first index is used for rows, the second index is used for columns. 8.1.12.AP.3: Select and combine control structures for a specific application based Create and initialize a 2D array by using upon performance and readability, and initializer lists that represent 1D arrays. identify trade-offs to justify the choice. Use square brackets [row][col] to access and modify an element in a 2D array. 8.1.12.AP.4: Design and iteratively develop computational artifacts for practical intent,

48

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit VIII: Two-Dimensional Arrays personal expression, or to address a societal 2D arrays may be traversed row-by-row or Recall that “row-major order” refers to an issue. column-by-column. ordering of 2D array elements where traversal occurs across each row, while 8.1.12.AP.5: Decompose problems into “column-major order” traversal occurs down smaller components through systematic each column. analysis, using constructs such as procedures, modules, and/or objects. Nested iteration statements are required to Use nested iteration statements to traverse traverse each element of a 2D array. and access all elements in a 2D array. 8.1.12.AP.6: Create artifacts by using Write nested iteration statements to traverse procedures within a program, combinations the 2D array in “row-major order” or of data and procedures, or independent but “column-major order.” interrelated programs.

8.1.12.AP.7: Collaboratively design and develop programs and artifacts for broad The outer loop of a nested enhanced for loop The enhanced outer for loop variable must be audiences by incorporating feedback from used to traverse a 2D array typically the type of each row, which is a 1D array. users. traverses the rows, while the inner is reserved for the columns. The inner enhanced for loop variable must be the same type as the elements stored in the 8.1.12.AP.8: Evaluate and refine 1D array. computational artifacts to make them more usable and accessible. Sequential/linear search algorithms must be Explain the required algorithmic applied to each row of a 2D array after modifications for all standard 1D array 8.1.12.AP.9: Collaboratively document and accessing those rows individually. algorithms to be applied to 2D array objects. present design decisions in the development of complex programs.

KEY TERMS: 2D arrays, traverse, row- major, column-major 49

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit VIII: Two-Dimensional Arrays

ASSESSMENT EVIDENCE: Students will show their learning by: • Designing a text-based battleship game using a two-dimensional array. KEY LEARNING EVENTS AND INSTRUCTION: • Students develop and implement image manipulation algorithms in a graphics context. • Students program a simplistic game with graphics only constituting of textual output. SUGGESTED TIME ALLOTMENT 2 weeks SUPPLEMENTAL UNIT RESOURCES Edhesive.com – AP Computer Science A course

https://apcentral.collegeboard.org/courses/ap-computer-science-a/classroom-resources/lab- resource-page?course=ap-computer-science-a – College Board AP CSA Resources

https://codingbat.com/java – Coding Bat practice problems

https://www.java67.com/2014/10/how-to-create-and-initialize-two-dimensional-array-java- example.html – Java67 2D Arrays

https://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html – Java Arrays API

50

Randolph Township Schools Randolph High School AP Computer Science A Curriculum

Unit IX: Inheritance

TRANSFER: Streamline the code development process through implementation of inheritance and polymorphic relationships.

STANDARDS / GOALS: ENDURING UNDERSTANDINGS ESSENTIAL QUESTIONS

8.1.12.CS.1: Describe ways in which When multiple classes contain common • How does inheritance make a integrated systems hide underlying attributes and behaviors, programmers create programmer’s job easier? implementation details to simplify user a new class containing the shared attributes • How can the superclass/subclass experiences. and behaviors to form inheritance relationship be compared and relationships, one of the core principles of an contrasted to the parent/child 8.1.12.CS.2: Model interactions between object-oriented programming model. relationship? application software, system software, and hardware. Modifications made at the highest level of • How can programmers adapt the

class hierarchies apply to the subclasses. behavior of a superclass without 8.1.12.AP.1: Design algorithms to solve propagating those changes to all computational problems using a combination subclasses? of original and existing algorithms. • How can programmers define shared 8.1.12.AP.2: Create generalized behavior in class hierarchies without computational solutions using collections knowing all potential subclasses? instead of repeatedly using simple variables. Polymorphism is one of the core principles • How can polymorphism ensure code 8.1.12.AP.3: Select and combine control of an object-oriented programming model may be used for a wider variety of structures for a specific application based and involves provision of a single interface applications? upon performance and readability, and to entities of different types. identify trade-offs to justify the choice.

51

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit IX: Inheritance

8.1.12.AP.4: Design and iteratively develop KNOWLEDGE SKILLS computational artifacts for practical intent, Students will know: Students will be able to: personal expression, or to address a societal Superclasses represent the “parents” to the Develop a class hierarchy by putting issue. subclass “children” in an inheritance common attributes and behaviors of related relationship. classes into a single class called a superclass. 8.1.12.AP.5: Decompose problems into Develop subclasses from classes by drawing smaller components through systematic upon the existing attributes and behaviors of analysis, using constructs such as procedures, the superclass without repeating code. modules, and/or objects. Create an “is-a” relationship by extending the 8.1.12.AP.6: Create artifacts by using subclass from the superclass. procedures within a program, combinations of data and procedures, or independent but Recognize that a class can extend only interrelated programs. one superclass, but a class may have any number of subclasses. 8.1.12.AP.7: Collaboratively design and Writing the constructor of a subclass either Recall constructors are not inherited. develop programs and artifacts for broad implicitly or explicitly requires execution of audiences by incorporating feedback from any superclass constructors. Write code using the keyword “super” and users. passing appropriate parameters to the superclass constructor from the first line of a 8.1.12.AP.8: Evaluate and refine subclass constructor. computational artifacts to make them more usable and accessible. Recognize that when a subclass’s constructor does not explicitly call a superclass’s 8.1.12.AP.9: Collaboratively document and constructor, Java inserts a call to the present design decisions in the development superclass’s no-argument constructor. of complex programs.

52

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit IX: Inheritance

The process of calling superclass All constructors within a class hierarchy constructors continues until the Object (called explicitly or implicitly) execute constructor is called. beginning with the Object constructor. Method overriding occurs when a public Define a method within its accessing class or method in a subclass has the same method a superclass. signature as a public method in the superclass. Develop a subclass to have modified (overridden) or additional methods or instance variables. Recall a subclass will inherit all public methods from the superclass; these methods remain public in the subclass. Polymorphism is the provision of a single Assign an object of type S to a reference of interface (or, in our case, superclass) to type T, when S is a subclass of superclass T, entities (in our case, subclasses) of different to facilitate polymorphism. types. Demonstrate that if S is a subclass of T, then a reference of type T can be used to refer to an object of type T or S. Declare references of type T, when S is a subclass of T, in the following declarations: - Formal method parameters - arrays – T[] var, when array objects may be T or S - ArrayLists – ArrayList var, when ArrayList objects may be T or S

53

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit IX: Inheritance

The “super” keyword can be used to call a Use the keyword “super” to call the superclass’s constructors and methods. superclass method and pass appropriate parameters from the subclass. Object type and inheritance relationships are Determine the correctness of a non-static both important with regards to non-static method, during compiling, by the declared method call validity. type of methods use or inherited. Demonstrate that at run-time, the method in the actual object type is executed for a non- static method call. The Object class is the superclass of all other Utilize the Object class through inheritance. classes in Java. Recognize that the Object class is part of the java.lang package. Define the following Object class methods, including what they do and when they are used: - boolean equals(Object) - String toString() Recognize that subclasses of Object often override the equals and toString methods with class-specific implementations.

KEY TERMS: class, subclass, superclass, toString, Object, inheritance, hierarchy, polymorphism, overriding

54

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit IX: Inheritance

ASSESSMENT EVIDENCE: Students will show their learning by: • Creating several simple, related classes to represent Ultimate Frisbee team members. • Modifying previously-created Fraction classes to implement the Comparable interface.

KEY LEARNING EVENTS AND INSTRUCTION: • Students explore, adapt, and implement components of Elevens, a simplified solitaire game. • Students implement existing interfaces and override existing methods they have not written into novel programs. SUGGESTED TIME ALLOTMENT 3 weeks SUPPLEMENTAL UNIT RESOURCES Edhesive.com – AP Computer Science A course

https://apcentral.collegeboard.org/courses/ap-computer-science-a/classroom-resources/lab- resource-page?course=ap-computer-science-a – College Board AP CSA Resources

DrJava.org – DrJava IDE

https://codingbat.com/java – Coding Bat practice problems

https://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html – Oracle Tutorial Inheritance

https://www.w3schools.com/java/java_polymorphism.asp – W3 Ploymorphism

55

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit X: Recursion

TRANSFER: Trace recursive method calls and compare efficiency of programming and execution with iterative approaches.

STANDARDS / GOALS: ENDURING UNDERSTANDINGS ESSENTIAL QUESTIONS

8.1.12.CS.1: Describe ways in which Recursive problem solutions depend on the • What stops a recursion from being an integrated systems hide underlying solutions to increasingly smaller cases of the infinite process? implementation details to simplify user same base problem. experiences. Recursive problem solutions may be • How can recursions be 8.1.12.CS.2: Model interactions between replicated, often more tediously, through compared/contrasted to iterative application software, system software, and iterative approaches. processes? hardware. KNOWLEDGE SKILLS 8.1.12.AP.1: Design algorithms to solve Students will know: Students will be able to: computational problems using a combination A recursive method is a method that calls Recognize that recursive methods contain at of original and existing algorithms. itself. least one base case, which halts the recursion, and at least one recursive call. 8.1.12.AP.2: Create generalized computational solutions using collections Outline the local scope of variables in each instead of repeatedly using simple variables. recursive call, including the formal parameters. 8.1.12.AP.3: Select and combine control structures for a specific application based Liken parameter values capturing the upon performance and readability, and progress of a recursive process, to loop identify trade-offs to justify the choice. control variable values capturing the progress of a loop.

56

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit X: Recursion

8.1.12.AP.4: Design and iteratively develop Every recursion may be converted to an Compare recursive problem solutions to computational artifacts for practical intent, iterative approach. replicated iterative approaches. personal expression, or to address a societal issue. Describe how recursion can be used to traverse String, array, and ArrayList objects. 8.1.12.AP.5: Decompose problems into Standard sorting algorithms may be more Explain why the binary search algorithm smaller components through systematic efficiently programmed through recursive requires data to be in sorted order. analysis, using constructs such as procedures, processes, as opposed to iterative processes. modules, and/or objects. Outline the progress of the binary search algorithm for given search values and data 8.1.12.AP.6: Create artifacts by using structures. procedures within a program, combinations of data and procedures, or independent but Compare the merge sort recursive algorithm interrelated programs. that can be used to sort elements in an array or ArrayList with the linear and insertion sort 8.1.12.AP.7: Collaboratively design and iterative algorithms. develop programs and artifacts for broad audiences by incorporating feedback from KEY TERMS: recursion, base case, binary users. search, merge sort

8.1.12.AP.8: Evaluate and refine computational artifacts to make them more usable and accessible.

8.1.12.AP.9: Collaboratively document and present design decisions in the development of complex programs.

57

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit X: Recursion

ASSESSMENT EVIDENCE: Students will show their learning by: • Tracing recursive method calls to provide execution counts and output. • Likening recursive processes to natural and geometric phenomena, such as fractals and snail shells. KEY LEARNING EVENTS AND INSTRUCTION: • Students map out recursive method calls using pen and paper. SUGGESTED TIME ALLOTMENT 2 weeks SUPPLEMENTAL UNIT RESOURCES Edhesive.com – AP Computer Science A course

https://apcentral.collegeboard.org/courses/ap-computer-science-a/classroom-resources/lab- resource-page?course=ap-computer-science-a – College Board AP CSA Resources

DrJava.org – DrJava IDE

https://codingbat.com/java – Coding Bat practice problems

https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/RecursiveAction.html – Oracle Tutorial Recursion

https://www.geeksforgeeks.org/recursion-in-java/ – Geeks for Geeks Recursion in Java

58

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit XI: Extra Post-AP Exam Projects

TRANSFER: Develop a working computer game incorporating a Graphical User Interface (GUI).

STANDARDS / GOALS: ENDURING UNDERSTANDINGS ESSENTIAL QUESTIONS

8.1.12.CS.1: Describe ways in which “Rules” within computer games, at their • How are game rules enforced in integrated systems hide underlying most basic programming level, are Boolean program code? implementation details to simplify user logic statements. • How can programmers evoke experiences. separate processes within a game concurrently? 8.1.12.CS.2: Model interactions between application software, system software, and Individual components of computer games • Is creating a new class ever more hardware. with specific characteristics and abilities are trouble than it’s worth? generated through Java class blueprints as • How can programmers encapsulate 8.1.12.AP.1: Design algorithms to solve instances of those classes. game behavior in a class separate computational problems using a combination from one to handle graphics alone? of original and existing algorithms. User interaction with a GUI is handled • How is the choice of a listener 8.1.12.AP.2: Create generalized through listeners added to GUI components. informed by a program’s eventual computational solutions using collections user? instead of repeatedly using simple variables. KNOWLEDGE SKILLS Students will know: Students will be able to: 8.1.12.AP.3: Select and combine control An understanding of programming is vital for Translate behavior of simple computer structures for a specific application based the design and implementation of computer games to program code. upon performance and readability, and games. identify trade-offs to justify the choice. Design novel classes to represent elements of a selected computer game.

59

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit XI: Extra Post-AP Exam Projects

Explore and incorporate information from online sources for novel purposes in their 8.1.12.AP.4: Design and iteratively develop games. computational artifacts for practical intent, personal expression, or to address a societal It often makes more sense to adapt existing, Modify working Elevens lab code for use in issue. proven code than to start from scratch. a different computer game. Adapt the overridden paintComponent and 8.1.12.AP.5: Decompose problems into repaint methods for incorporation of new smaller components through systematic graphics. analysis, using constructs such as procedures, modules, and/or objects. Synthesize information from uncommented code written by another programmer. 8.1.12.AP.6: Create artifacts by using procedures within a program, combinations Provide citation and attribution for code of data and procedures, or independent but borrowed from online sources and interrelated programs. incorporated into their games. The Java Graphics class may be used to draw Draw a number of shapes to a working GUI 8.1.12.AP.7: Collaboratively design and simple shapes to a GUI. in using several Graphics class methods, develop programs and artifacts for broad including: audiences by incorporating feedback from - drawLine(int, int, int, int) users. - drawOval(int, int, int, int) - drawArc(int, int, int, int, int, int) 8.1.12.AP.8: Evaluate and refine - drawRect(int, int, int, int) computational artifacts to make them more - drawPolygon(int[], int[] int) usable and accessible. Modify the color of drawn components using the setColor(Color) method, as well as constants of the Color class.

60

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit XI: Extra Post-AP Exam Projects

8.1.12.AP.9: Collaboratively document and present design decisions in the development of complex programs. The Java package incorporates several Incorporate instances of the following Swing related classes for display of common GUI package classes into working GUI programs, elements. including: - JFrame - JPanel - JButton - JLabel - Timer The Java event package incorporates several Add ActionListeners and MouseListeners to related classes for user interaction with GUI GUI components for clickable user elements. interaction. Use the KeyListener or KeyStroke classes with GUI components for accepting keyboard input from users.

KEY TERMS: Graphical User Interface (GUI), Graphics, Swing, listener

ASSESSMENT EVIDENCE: Students will show their learning by: • Developing a working version of a commonly-known game in Java, including a GUI component. KEY LEARNING EVENTS AND INSTRUCTION: • Students rigorously test programs devised entirely on their own, with self-created guidelines on what must be included. • Students adapt and incorporate existing code into novel programs, giving attribution.

61

Randolph Township Schools Randolph High School AP Computer Science A Curriculum Unit XI: Extra Post-AP Exam Projects

SUGGESTED TIME ALLOTMENT 5 weeks SUPPLEMENTAL UNIT RESOURCES Edhesive.com – AP Computer Science A course

https://apcentral.collegeboard.org/courses/ap-computer-science-a/classroom-resources/lab- resource-page?course=ap-computer-science-a – College Board AP CSA Resources

DrJava.org – DrJava IDE

https://www.ntu.edu.sg/home/ehchua/programming/java/J4a_GUI.html – Java GUI Tutorial

https://www.clear.rice.edu/comp310/JavaResources/GUI/ – Rice Java GUI Tutorial

https://docs.oracle.com/javase/tutorial/uiswing/ – Oracle Trail: Creating a GUI

62

Randolph Township Schools Randolph High School AP Computer Science A Curriculum APPENDIX A Java IDEs: DrJava.org https://www.bluej.org/ https://codenvy.com/ https://www.greenfoot.org/download

Java – https://www.java.com/en/

Developer Resources: https://developer.oracle.com/java/ https://community.oracle.com/welcome https://www.amazon.com/Java-Developers-Resource-Line-Supplement/dp/0135707897 https://go.java/developer-opportunities/

AP Test Preparation Supplements: https://www.albert.io/ https://apstudents.collegeboard.org/courses/ap-computer-science-a/assessment https://codehs.com/info/curriculum/apjava https://www.khanacademy.org/computing/ap-computer-science-principles/ap-csp-exam-preparation

AP Computer Science A: With 6 Practice Tests (Barron's Test Prep) Ninth Edition by Roselyn Teukolsky M.S.

Cracking the AP Computer Science A Exam, 2020 Edition: Practice Tests & Prep for the NEW 2020 Exam (College Test Preparation) by The Princeton Review

63

Randolph Township Schools Randolph High School AP Computer Science A Curriculum APPENDIX B

Opportunities exist for interdisciplinary units with courses such as Physics, Business, Technology, Robotics, or other science and mathematics courses and electives.

64

Randolph Township Schools Randolph High School AP Computer Science A Curriculum APPENDIX C AP Computer Science A is a required course in the Computer Science and Programming Pathway, typically following AP Computer Science Principles and Programming with Python & Java Honors. The complete sequence of courses, with both required and choice selections, is both below and available at https://www.rtnj.org/domain/1185.

65