|
Mr. Rogers AP Computer Science A - Second Quarter Objectives |
| Syllabus | 1st Quarter | 2nd Quarter | 3rd Quarter | 4th Quarter |
|
| Essential Question: Do we live in a binary world? |
Chapter 7: Boolean Expressions and Conditional Control
Define conditional control.
Correctly use both if and if-else statements. (Be as one with the four Common if-else Errors on p. 156.)
Draw flowcharts for both if and if-else statements.
Correctly use boolean relational operators. == , > , < , >= , <= , !=
Correctly use boolean logical operators. && , || , !
Given a set of logic gates write the associated boolean expression (p. 3).
Write truth tables for "and", "or", and "xor" gates.
Evaluate complex boolean statements using correct order of operators (p. 163).
Highest ^ ^ ^ ^ Lowest
! (unary) - (cast) ++ -- * / % + - == < <= > >= != && ||
Correctly describe and use short-circuit evaluation.
Correctly use if-else-if tables for menus and selection processes like tax tables (see example code).
Correctly use switch statements. (Be as one with the six points on p. 197)
Summative Assessment : Test Chap 11 Objectives 1-11
| Essential Question: How can we access and perform similar manipulations on millions of volatile pieces of similar information without having to create millions of lines of code? |
Chapter 8 Iterative Statements (Loops)
Relevance: Many if not most algorithms require loops. Loops are basic to all forms of computer science.
- initialization
- testing
- incrementing
Loop Type
Example Comments for
- int x;
- for (x = 0; x < n; x++) {
- ... code
- }
Used when the number of times the loop needs to run is known
while
- int x = 0;
- while (x < n) {
- x++;
- ... code
- }
Used when the number of times the loop needs to run is not known
do...while
- int x = 0;
- do {
- x++;
- ... code
- } while (x < n);
Used when the number of times the loop needs to run is not known but must be at least once.
foreach
- double y [ ] = new double [n];
- for (double i: y) {
... code
}Always runs exactly n times where n = size of list. Starts at list index of 0 and increments upwards by one
- even/odd numbers
- factorials
- fibonacci numbers
- Homefun (summative/formative assessment):
- Exercises 8, 9, 13
- Lab 8.6; Exercise 10, 11, 12
Even numbers: write a program that outputs n even numbers. Use command line input to input the value of n. output 1 even number per line.
Fibonacci Numbers: write a program that outputs n fibonacci numbers. Use command line input to input the value of n. output 1 fibonacci number per line.
Prime numbers: write a program that outputs n prime numbers. Use command line input to input the value of n. output 1 prime number per line.
Summative Assessment: Test Chap 8 Objectives 1-12
| Essential Question: Why use objects instead of just using variables? |
Chapter 9: Implementing Classes and Using Objects
Properly declare a class.
Explain why fields are usually declared private and methods public.
Correctly declare and initialize (generally with the new operator) objects
Be as one with the nature of methods.
must be called to run
run sequentially from top to bottom unless branched
can be called repeatedly
when finished returns control of the program to the place the method was called.
contain a small highly focused program or algorithm.
modular and reusable
defined in a class
a form of control abstraction in which a single line of code that calls the method, can be used to perform a useful function without having to know all the details of how the method's code is written.
static (called by a class name) or instance (called by an instance)
Correctly write the header which declares a method inside a class.
access (public or private) returnType methodName (type parameterName1, ... type parameterNameN)
Explain the terms precondition and post condition as they relate to methods and procedural abstraction.
Explain how assertions and runtime exceptions are used in debugging, especially for reusable code.
Correctly use comments with method declarations so that a programmer could use the method without knowing the details about how the code is implemented.
Explain the nature of parameters.
creates a local variable inside the method
used for passing values into the method
when using objects can also pass a value out of the method
Explain the difference between an argument and a parameter.
Correctly use overloaded methods. (Same name different arguments)
different numbers or types of parameters
return type must be the same.
Correctly use constructers.
name is identical to the class name
no return type, not even void
can be overloaded
not required
Correctly use copy constructors.
State when the default constructer runs and how it initializes fields.
numbers = 0
booleans = false
references = null
Correctly use the "final" reserved word.
Correctly initialize objects and use the new operator (p. 224).
Homefun: read Sections 9.1 - 9.5; Exercises 1-6
State which type of fields can be accessed and what type methods can be called using a static method. (p. 223).
can access static field - only one value & one memory address
can call static method
can access instance field of a different class
can call instance method of a different class
State which type of fields can be accessed and what type methods can be called using an instance method (p. 223).
instance field - Many values & memory addresses. A field has one value per object
static field - Only one value & memory address
instance method
static method
Correctly call both static and instance methods (p. 226).
Use class name & dot operator when calling static methods from another class.
Use object & dot operator when calling instance methods from another class.
Class name & dot operator are optional when calling static methods in a class.
Use "this" & dot operator or nothing when calling instance methods in a class.
Compare the two ways to pass arguments to methods and constructers (p. 230).
Primitive data types are always passed as values--the variable containing the value and the value ceases to exist after the method has run
Objects are always passed as references--the address of a memory location that continues to exist after the method has run.
Correctly use return statements.
Summative Assessment: Test Chap 9 Objectives 1-20
| Essential Question: How can we store and manipulate not just numbers but human text in a computer program? |
Chap. 10 Strings
- String ()
- String (String s)
- String s1 = " "; // s1 is set to an empty String
- String s2 = new String(); // s2 is set to an empty String
- String s3; // s3 is set to null
- length()
- charAt (pos) // Note that characters are counted starting at 0.
- substring (pos)
- substring (fromPos, toPos)
- compareTo (s2) // returns neg int if s1 <s2, 0 if s1 = s2, pos int if s1>s2
- compareToIgnoreCase (s2) //returns neg int if s1 <s2, 0 if s1 = s2, pos int if s1>s2 ignoring case
- equals(s2) // returns a boolean true or false
- equalsIgnoreCase(s2) // returns a boolean true or false ignoring case
- indexOf (ch) // four types
- lastIndexOf (ch) // four types
- trim() // removes white space characters from beginning and end of string
- replace (oldChar, newChar)
- toUpperCase()
- toLowerCase()
- yourString += str;
- yourString = yourString1 + str;
- yourString.concat (str);
examples:
Integer.parseInt(yourString)
String.valueOf(yourNumber)
|
|
|
|
|
|
Summative Assessment: Test Chap 10 Objectives 1-13
| Essential Question: How does OOP development using Java compare with the process of writing a book using English? |
Chapter 11: Class Hierarchies and Interfaces
Relevance: Class Hierarchies and Interfaces make it easier to organize and manage the creation and maintenance of large software projects similar to the way the table of contents, chapters, and appendices help organize books.
Examples:
- overriding of methods
- overloading of methods
- Example declaration:
- public abstract int tax(); // Note that there is no code, not even brackets.
- Example declaration:
- public abstract class People {
- . . .
- }
- Example declaration:
- public interface Career {
- . . .
- }
Has no abstract methods.
interface -- contains only abstract methods, no instances of the interface are allowed
abstract class -- contains one or more abstract methods. no instances of the abstract class are allowed
concrete class -- contains no abstract methods. Instances of the concrete class are allowed
- A class can only extend one class but can implement multiple interfaces.
- Interfaces make code readable and uniform by standardizing the labeling of procedures (methods).
- a superclass's constructors must be used to initialize private fields
- a superclass's constructors can be called inside the subclasses constructor using super (<appropriate arguments>);
- if the superclass's constructor is not called the no-arguments-constructor of the superclass is run by default
- if there is not a no-arguments-constructor, an error message results
Homefun (summative/formative assessment): Exercises 1-5
Programming assignments: 6a
Pumpkin Farm Simulation: Create the following:
Squash class -- has a private weight field and a grow method that adds a random double between zero and 10 to weight each time it's run (representing one week's growth).
Pumpkin class -- inherits the Squash class
Crop interface -- contains 1 abstract method called yield
PumpkinFarm class -- implements Crop, creates a local (in the main method) object array of ten pumpkins and grow them for 10 weeks. Outputs the total weight of pumpkins using the yield method.
Summative Assessment: Test Chap 11 Objectives 1-15
| Essential Question: How can we store millions of volatile pieces of similar information without having to create millions of variables in a computer program? |
Chap. 12 Arrays and ArrayLists
- int scores [ ] = new int [5];
- int scores [ ] = { 93, 67, 99, 87, 91};
- numbers = 0
- boolean = false
- objects = null
example of a method's parameters : addUp ( int incomes [ ]);
example of calling an : addUp ( incomes);
Note: the [ ] in the example indicates that an array is being passed to the method. Do not put the size of the array in the brackets.
- final int ROWS = 2;
- final int COLS = 3;
- double name2DArray [ ] [ ] = new double [ROWS][COLS];
- or
- double name2DArray [ ] [ ] =
- {
- {0.0, 2.7, 5.6},
- {4.3, 1.4, 7.2}
- };
- twoDArray.length gives the number of rows
- twoDArray[0].length gives the number of columns
- Name Salary $1000/yr
- Bob Arnold 90
- Herb Bobo 12
- Jane Cool 27
- Alfred Nameless 49
- Juan Smith 200
- Betty Taylor 142
Next, output the total of all salaries. Use a random number generator to fire two employees. Remove them from the Array List then add a new employee called Bob Newguy with a salary of $200,000. Again, output a table with the names of the current employees and their salaries. Also output the total of all salaries.
Note: You need to write the letters on graph paper or in an Excel spread sheet in order to understand how many spaces are needed. To understand how the arrays should be initialized look at chapter 10 objective 7 above. You do not need to reproduce the grid lines in your program's output.
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | |
| 0 | A | ||||||||||
| 1 | A | A | |||||||||
| 2 | A | A | |||||||||
| 3 | A | A | A | A | A | A | A | ||||
| 4 | A | A | |||||||||
| 5 | A | A |
Summative Assessment: Test Chap 12 Objectives 1-16