Mr. Rogers AP Computer Science A - First Quarter Objectives |
Essential Question: How do you create a program? |
Chapter 1 & 2: Software Basics
(AP Computer Science Standard: II Program Implementation, III Program Analysis, VI Computing in Context)
First Day
Introduction - View Mr. Rogers AP Computer Science Syllabus (google mr rogers comp sci. Syllabus is 1st link.) and set up Bluej (click on the picture of the blue jay shown below).
Programming Assignment 1: Using the Bluej IDE, Create a project called Hello with a class also called Hello. Write a program that outputs "Hello World" to the screen.?
(Click here to see the code.)
Key principles to review:
- Java programs must have at least one class.
- Java programs must have at least one method.
- The main method is used for starting a program.
- Java is case sensitive. Method is not the same as method.
Deliberately delete a ";" from the above program and note the error message. Deliberately alter other elements of the program to see what happens
Essential Question: What features make Java special? |
Second Day
Key principles to review:
Essential Question: What is a run time error? |
Programming Assignment 3: Write a program that inputs (your name) and (your age) on the command line and outputs "Hello (your name) you are (your age) years old".
Deliberately cause a run time error in? the above program and note what happens.
Programming Assignment 4: Modify the above program so that it does the output using a method called output. Pass the information about your name and age from the main method into the output method.
Deliberately cause a run time error in the above program and note what happens.
Essential Question: What does a loop do? |
example: in pounding a nail, each time the nail is struck by the hammer is one iteration.
Sample code: (Note, putting // before a line of code makes it a comment. Comments are ignored when a program is run.)
for (int x = 0; x < 10; x ++) {
- // Insert your lines lines of code between
- // the curly brackets.
}
Formative assessments:
Programming Assignment 5: Modify Programming Assignment 2 with a "for loop" so that the message repeats itself 10 times.
once the program is running, modify it so that it has an infinite loop and see what happens when you run it.
- Change System.out.println to System.out.print and note what happens. alter your code by adding a ; as shown below and note what happens.
for (int x = 0; x < 10; x ++) ; {
Essential Question: What do classes and methods do and why are they important to functional decomposition? |
Remainder of Week
Programming Assignment 6: Set up and run the Hello2Class project (click on the links in the blueJ screen shot show below).
a) Try eliminating the word static found in the boys class and note the effect.
b) Set up a "for loop" that calls the talk method in the girls class 3 times.
c) Create a Parent class with a talk method that not only outputs a unique message but also calls the girls talk method. Call the Parents talk method in the Hello2Class class.? ?
d) Give an example of encapsulation from the program.
f) Give an example of information hiding from the program.
Essential Question: What is Gridworld and why learn about it? |
Note: Mastery of the case study often means the difference between a 4 and 5 on the AP Exam. Start early and give it priority!
- Go to the College board site and download the... Student Manual (.pdf/630KB)
- Download the................................................................. Code (.zip/238KB)
- Download and follow the............................................. Installation Guide (.pdf/172KB) for BluejB
- (column number, row number)
- column numbers start with 0 on the left and increase as the columns go to the right.
- row numbers start with 0 at the top and increase as the rows go downward.
- the cell in the upper left hand quarter is labeled 0, 0
Assignments: The below assignments are to be completed within the first 10 days of school.
All Homefun (sometimes improperly referred to as homework)? assignments are to be turned in on the day of the test. They are to be stapled to the back of the test paper. The one exception are items on 3x5 cards. These will be checked separately one or more times each quarter. Late Homefun will NOT be accepted.
3x5 Cards ? are to be made in class on a daily basis students without 3x5 cards are not participating. The 3x5 indicates items that are especially3x5 card worthy.
Homefun (summative/formative assessment):
GridWorld: Read Section 1; Do exercises 1-4. Note: you will not understand all of the terminology. Don't worry: your not supposed to. However, you'll find that if you don't let the jargon bother you, you can muddle through. In programming, muddling is a highly valued art. In the past, a good working knowledge of the case study has often made the difference between a 4 and a 5 on the AP Exam.
Each Programming assignment is to be set up in a separate project and placed on your student virtual hard drive on or before the day of the unit test.
Programming Assignment 7: Write a program that receives three input characters via command line input and outputs your printed initials in large size (at least 2 inches high) using the 3 input characters stored in string variables. Note: you need to write the initials on graph paper in order to know how many spaces to put between the string variables.
Example 1:
Input: "T", "K", "R"
Output:
T T T T T K K R R R R T K K R R T K K R R R R T K K R R T K K R R Example 2:
Input: "X", "Y", "Z"
Output:
X X X X X Y Y Z Z Z Z X Y Y Z Z X Y Y Z Z Z Z X Y Y Z Z X Y Y Z Z
Programming Assignment 8: Write a program that uses a "for loop" to output a quilt-like pattern out of characters. It should have at least 2 different patches, repeated twice.
example:
- x x x o o o x x x o o o
- x x x o o o x x x o o o
- x x x o o o x x x o o o
Programming Assignment 9: Set up a project called BoomDemo with a single class called BoomDemo and insert the code shown here. Run the code then modify it as follows:
- Change the speed of the dots as they explode apart. (Note: the numbers cannot be higher than 255.)
- By modifying the code, determine the meaning of the 3 numbers used for representing new colors.
- Change the dot color to yellow (hint: google rgb yellow ).
- Add 3 new sets of dots, a pair that explodes vertically, a pair that explodes horizontally, and a pair that explodes along the opposite diagonal from the existing pair of dots.
- Google Java 7 graphics, select the 1st link, and choose a different shape for the dots. The 1st link will take you into the Java applications programming interface (API). It tells you how to use various features provided within the Java language. It is an awesome resource that you will frequently use.?
- Do something of your own choosing to modify the program to your liking.
Read Sections: 2.1 to 2.3
Summative Assessment: Unit Test Chap 1 & 2 Objectives 1-14
Vocabulary Homefun: You must have at least one 3x5 card for each term. The information can be a definition or an analogy. Questions about the terms in orange bold type are generally found on the AP Exam and on Mr. Rogers' tests.
compiler | calling a method | machine language | encapsulation | |
interpreter | debugging | source code | information hiding | |
class | compiling error | byte code | functional decomposition | |
method | run-time error | Java virtual machine (VM) | string | |
field | logic error | IDE | concatenate |
Essential Question: What is a computer? |
Chapter 1 & 2 (continued): Hardware Basics
(AP Computer Science Standard: VI Computing in Context)
- bit--a binary digit
- byte--8 bits
Name
Abbreviation Number of Bytes
old New
kilobyte kB 210 1,000 or 103 megabyte MB 220 1,000,000 or 106 gigabyte GB 230 1,000,000,000 or 109 terabyte TB 240 1,000,000,000,000 or1012
- not
- and
- or
- xor (can be made from the 3 gates shown above)
3 Person Group Assignment:
- Create a digital circuit using gates that describes an activity (must use both "and" as well as "or" gates, 5 gates minimum).
- Create an xor gate from "not", "and" and "or" gates.
- stand-alone applications (single user)--word processors, spread sheets, etc.
- information sharing and communication--various mark up languages such as html (used on web pages)
- distributed software--applets (use java language), java scripts (not java!), server side software, etc
- cluster computing--Beowulf systems, SETI
Read Sections: 1.1 to 1.4
?
Essential Question: How are numbers, letters, and colors represented in computers? |
Chapter 1 & 2 (continued): How Information is Represented
- State which comes first upper or lower case numbers. Upper case comes first.
- Write a program that converts a lower case character to upper and vice versa and converts a character to the Unicode number used to represent it.
Code Type Bytes Possible Characters ASCII 1 256 Unicode (used in Java) 2 65,536
max # = (2n - 1)
?
Essential Question: What is the most important part of a piece of software's life cycle? |
(AP Computer Science Standard: I Object-Oriented Program Design)
- Pseudo code--English language-like representation of code that looks code-like and describes the detailed operation of a program. Pseudo code does not follow the syntax of any particular programming language.
- Flow Charts--use PowerPoint
|
|
|
|
- isolation testing--classes and libraries are tested separately
- boundary condition testing--boundaries are identified and used for generating test data.
- integration testing--all of the software's components are combined and tested as a unit.
Read Chap. 2
Homefun (summative/formative assessment):
Exercises 1, 6, p. 38
Use a flow chart to represent algorithms containing a loop
- multiplication using only addition
- division using only subtraction
Programming Assignments:
- Exercises 14, (15 &16) in same program
- Write a really cool applet that moves three or more different types of graphic elements around the screen while changing their color and size. Output a stationary title for the applet in the center of the screen so that it is never obscured by the moving elements. The elements are to look like they move under the writing. Use a timer to control the speed of the animation.
Summative Assessment: Test Chap 1 & 2 Objectives 1-24--come prepared to write an applet on paper
(AP Computer Science Standard: I Object-Oriented Program Design, II Program Implementation)
Essential Question: What basic vocabulary is needed to talk about Java ? |
Features in Java
wild card - The wild card or * causes all the classes of a package to be included in a program. example: import javax.swing.*
instance - a data record with unique values stored for each of the non-static fields in a class.
object - see instance above.
methods - the name of the method is always followed by a set of parentheses. example: calculateCost ( )
instance methods When used by a different class it is called with an instance of its home class, example: bob.getsOlder ( ). bob is an instance or object of the class containing the getsOlder method.
Static methods declared static in the method's 1st line of code. When used by a different class it is called with name of its home class, example Math.cos (5.9). Math is the class name. cos ( ) is a method inside the Math class. 5.9 is a double being passed to the cos method as an argument.
parameters--give data types. Parameters are contained in method's header and specify the arguments to be used when calling a method. example: computeTax (double income, int age). income and age are both parameters.
arguments--used when calling a method. example: computeTax (dollars, years). dollars and years are both arguments. Note: the data type of the argument must mach that of the parameter, but the name does not need to match.
overloaded methods -- two or more methods with the same name but different parameters. Overloaded methods typicall have different code inside them. Overloaded constructors are a special form of overloaded methods.
examples:
tax (double income)
tax (double income, double deductions)
constructor - are methods that establish the initial values of fields. Called with new operator when the object is created and allocated RAM. Must have the same name as the class.
field - a non-static data member (primitives or objects) of a class declared within the class (normally at the top) but not within a method. Has a specific value for each instance.
static -
A Java keyword used to define a variable as a class variable or a method as a class method.
Static methods & variables are called with the name of their class. Static variables are declared in a class but not in a method similar to fields. Unlike fields, static variables can store only a single value regardless of the number of instances of the class.event - starts or stops a procedure that is defined in a listener. Events are created by objects such as buttons, sliders, timers, etc.
listener - listeners are methods that respond to events. Programs using listeners must implement the appropriate interface that specifies the listener.
interface - uses the implements keyword. Interfaces are used for a variety of tasks including adding listeners.
- classes - Their names are always capitalized
Essential Question: How are classes used in ways that facillitate the buiding of massive programs with large numbers of programmers? |
|
Classes: ClassRoomExample, People |
instances
instance methods
static methods
overloaded constructors
Programming Assignment (summative/formative assessment):
Complete the Pumpkin Project as specified in the Farm class using the Pumpkin class. Note that this is an application not an applet. Applications start using a main method.
Essential Question: What is an applet? |
Applets reside on a server and are delivered over the internet by the server. However, when they run they run on your local computer, hence, there's no further load on the server. Applications reside on the hard drive of your local computer and run on your local machine. Server-side programs reside and run on servers, sending output to and receiving input from your local computer via the internet.
Because they are delivered over the internet, applets have security restrictions on them designed to prevent them from altering files on your local computer.
- Applets use init methods to start themselves by contrast, applications use main methods.
- Applets must extend either the Applet class or JApplet class
- Applets typically use a paint method for output.
Homefun (summative/formative assessment):
Write brief definitions for the terms in objective 1 that are highlighted as follows: Term. Use the textbook and the Oracle Java Glossary. Next find a program(s) with examples of each of the terms in objectives 1 and identify them. You may use programs from the book, the internet, or ones you've written yourself. You may work as a group.
Programming Assignment (summative/formative assessment):
Write a really cool applet that moves three or more different types of graphic elements around the screen while changing their color and size. Output a stationary title for the applet in the center of the screen so that it is never obscured by the moving elements. The elements are to look like they move under the writing. Use a timer to control the speed of the animation.
Summative Assessment: Test Chap 3 Objectives 1- 4
Essential Question: How can you implement encapsulation and information hiding in ways that reduce the amount of source code? |
Inheritance
|
|
Explain the "has-a" relationship. (Used for defining fields) 3x5
client, characteristic, or component relationship examples: A car has a motor. A store has a customer. A girl has a name. A class has a field.
Use "super" to call public methods of a super class from within a subclass.3x5
super.calculateHours ( double starTime, double stopTime);
Be aware that private fields in a superclass cannot be accessed in subclasses except by using a public get method that resides in the super class. 3x5
example : super.getWeight ( ) ; // returns the value of the superclass' private weight// field to a place in the subclass.
A superclass's protected fields can be used inside a subclass as though they were created in the subclass. Outside of the subclass, the field has to be access using a get method. 3x5
Explain the term "primitive data types" and give examples. These are data types that are fully defined within the Java language. a primitive data type will have a fixed memory allocation (in other words number of bytes used for storage of the value).
examples: int, char, double
Name four classes contained in the java.lang package which are automatically imported into your java programs.3x5
System
Math
Object
String
Programming Assignment: Write an applet with a Human class, Student class, School class and a Grades interface. The Human class will have a field for IQ and a constructor that can give it a unique value. The student class will have fields for name, test1, test2, and average grade. It will extend the Human class. The student class constructor will have parameters for initializing all the fields except average grade. The grades interface will have a method for calculating average grades. The student class will make use of the method that calculates average grade from the grades interface. The school is to have 3 students created in the school class and is to output all the school's information in a table as follow shown in the following example:
Name IQ Test 1 Test 2 Average Grade Bob 100 50 100 75 Jane 110 90 100 95 Martha 120 80 90 85
Summative Assessment: Test Chap 3 Objectives 1- 8