AP Computer Science A Jacobson Week 1 Second Semester.
-
Upload
augustine-hawkins -
Category
Documents
-
view
221 -
download
0
Transcript of AP Computer Science A Jacobson Week 1 Second Semester.
![Page 1: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/1.jpg)
AP Computer Science A
Jacobson
Week 1
Second Semester
![Page 2: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/2.jpg)
Agenda
• First Semester- Reflections
• Book Check (For Real)
• Marine Biology Case Study– Chapter 1
• Homework
• First Semester Grades
![Page 3: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/3.jpg)
Objectives for Today
• Today we will reflect upon the strengths and weaknesses of this class last semester, in both a verbal and written form.
• You will also observe, report and analyze the running marine biology case study.
![Page 4: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/4.jpg)
Reflection of First Semester
Fold a piece of paper (that you will turn in) in half “like a hot dog”
On the left, brainstorm all of the positive aspects of last semester.
On the right, brainstorm all of the roadblocks to your learning or things that could be better.
![Page 5: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/5.jpg)
Share with Class
![Page 6: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/6.jpg)
Mr. Jacobson’s Reflections
Positives
Hard work- Diligence
Problem solving skills are starting to show
Semester Project
![Page 7: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/7.jpg)
Mr. Jacobson’s Reflections
Negatives
![Page 8: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/8.jpg)
Mr. Jacobson’s Reflections
Semester Project
Great Job following directions
Needs more work on Object Oriented Programming concepts
Needs more work on algorithms
Battleship tutorial only helped 1 or 2 groups
![Page 9: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/9.jpg)
Mr. Jacobson’s Reflections
Places for Change
More responsive assessments
More student participation
Less “distractions”
![Page 10: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/10.jpg)
Book Check
• Collect all Simply Java
• Check the number of the other textbook
![Page 11: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/11.jpg)
Marine Biology Case Study
• What is the purpose?• Background• Chapters 1-4 in the Acrobat File for our class• Getting it running• Making Observations• Class discussion
![Page 12: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/12.jpg)
Marine Biology Case Study
• Getting it running
![Page 13: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/13.jpg)
Warm up
Assume that x is an initialized int variable. The code segment
if (x>5) x*=2;
if (x>10) x = 0;
Is equivalent to which of the following code segments?
A. x = 0;
B. if (x > 5) x = 0;
C. if (x >5) x*= 2;
D. if (x > 5) x = 0 else x*= 2;
E. if ( x > 5) x *=2; else if (x > 10) x = 0;
![Page 14: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/14.jpg)
Agenda
• Finish Chapter 1 Case Study– Work together– Class discussion
• Truth Tables
![Page 15: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/15.jpg)
Case Study
![Page 16: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/16.jpg)
![Page 17: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/17.jpg)
Objective-Truth tables
Today you will make a truth table for a complex logical expression and apply that to java programming.
![Page 18: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/18.jpg)
Truth Tables
• What data type is either TRUE or FALSE?– boolean
• What types of statement evaluate an expression that is either TRUE or FALSE?– if statements– while loops– For loops
![Page 19: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/19.jpg)
Simple Comparisons
( total == sum )
(x < 20)
( str.charAt(0) != str.charAt(9) )
NOTE: Here total, sum and x could be integers or doubles. “str” is a String and the method charAt() returns a character for comparison.
When there is only one comparison in the whole expression, it is easier to understand
![Page 20: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/20.jpg)
More Complex- Truth tables can help
( (X > 20) && (X < 30) )“&&” statements are true only if both parts are true
A B A &&B
T T T
T F F
F T F
![Page 21: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/21.jpg)
More Complex- Truth tables can help
( (X > 20) | | (X < 30) )“| |” statements are true if one or the other is true
A B A || B
T T T
T F T
F T T
F F F
![Page 22: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/22.jpg)
More Complex- Truth tables can help
( (X > 20) && ! (X < 30) )
A B !B A && !B
T T F F
T F T T
F T F F
F F T F
![Page 23: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/23.jpg)
Make a truth table
Make a truth table for the following expression
!A && !B
A B !A !B !A &&!B
T T F F F
T F F T F
F T T F F
F F T T T
![Page 24: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/24.jpg)
Equivalent Expressions
Two expressions are logically equivalent if their truth tables reveal that the same input results in the same output
! ( A && B) is equivalent to !A | | !B
Where A and B are logical expressions
![Page 25: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/25.jpg)
HW
From Book- p. 177 3.2, 3.3, 3.9, 3.10
Explain your answers in detail. (Hint- Make some type of truth table)
Due at beginning of next class
![Page 26: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/26.jpg)
Warm up
1. Consider writing a program to be used by a restaurant to keep track of the items on the menu, which include appetizers, main dishes and desserts. The restaurant wants to keep track, for every menu item, of the ingredients needed to prepare that item. Some operations will be implemented that apply to all menu itemsm and there will be some specialized
![Page 27: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/27.jpg)
Warm UpConsider the following two methodspublic static void printStuff(int x) {
int y=1;while (y < x) {
System.out.print(y + “ “);y *=2;if (y == x/2) return;}
}public static void mystery( ) {
int x = 8;while (x > 0) {
printStuff(x);x /= 2;
}System.out.println(“x=“ + x);
}
What will be the output when method mystery is called ?
A. 1 2 1 1 1 x=0
B. 1 2 1 1 x=0
C. 1 2 2 x=0
D. 1 2 4 x=8
E. 1 2 x=8
![Page 28: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/28.jpg)
Warm up picture
Mystery
x
printStuff (int x)
x
y
OUTPUT
![Page 29: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/29.jpg)
Agenda
• Warm Up
• Collect HW
• Chapter 4 Review- Group Presentations– Sections 4.0-4.5, 2.6, 2.0– 30 minutes to prepare– 5 minutes or less to present
![Page 30: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/30.jpg)
HW- you may start in class as needed
• P.240 true-false questions
• Provide justification for your answers– Give counterexample if false– Give explanation if true
• Read-Notes 248-255 (Start Chapter 5)
![Page 31: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/31.jpg)
Agenda
• Study Session• Tracing the Code- Continued• static modifier
– static variables– static methods
• HW- p.293 5.1-5.9 T-F Give Explanations• Notes- up to section 5.4
![Page 32: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/32.jpg)
Study Sessions
![Page 33: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/33.jpg)
Tracing the Code
• Where were we last time?
• Parameter Passing Example– Pages 253-255
![Page 34: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/34.jpg)
Agenda 2-17-06
• Collect HW
• Programming Projects p.294 5.1
• Finish the Chapter– interface
• Making one
• Using one
![Page 35: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/35.jpg)
Agenda 2-22-06
• Collect Missing Assignments• Finishing the Chapter- Interfaces• Programming Projects (Due by end of next
class)– P.294 5.2, 5.6, 5.7
• Test Chapter 4-5 (up to 5.4) Tuesday Feb 28th
![Page 36: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/36.jpg)
Time to Imagine…
Imagine a bunch of 4 year olds in the middle of a basketball court
![Page 37: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/37.jpg)
Time to Imagine…
And the adult in charge says “ OK, RUN!!!”What will happen?
![Page 38: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/38.jpg)
Time to Imagine…
Now imagine the same set up with the following exception:
![Page 39: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/39.jpg)
Time to Imagine…
A series of walls are put up. What will the kids do in this case?
![Page 40: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/40.jpg)
In Programming Chaos Should be avoided
• There needs to be some way for programmers to be organized and consistent
• One way this can be accomplished is through a well designed interface.
![Page 41: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/41.jpg)
interface - what is it?
• An interface looks like an “empty” class– All methods are abstract and public
• Headers for methods are listed but not implemented
– An interface has no data members– An interface may have constants
• public static final data
![Page 42: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/42.jpg)
More on interfaces
To use an interface for a class you are creating, you use the keyword “implements”
When a class implements a specific interface, it must create the details for each method that was listed in that interface.
![Page 43: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/43.jpg)
Example
Suppose you wanted to write a Geometry program about shapes. Ultimately, your program will be able to create and measure properties of many shapes, such as circles, squares, trapezoids, and possible a shape you do not know about yet.
Thinking “abstractly” what is something you would want to know about any shape in the program?
![Page 44: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/44.jpg)
“Shapes” interface
You can design a “Shape” interface that would force anyone who introduces a new shape to write code in an organized way.
public interface Shape{public double getArea();public void printCenter();public void makeVisible();}
![Page 45: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/45.jpg)
“Shapes” interface
You can design a “Shape” interface that would force anyone who introduces a new shape to write code in an organized way.
public interface Shape{public double getArea();public void printCenter();public void makeVisible();}
If I implement this interface, I
will have to make at least 3
methods
![Page 46: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/46.jpg)
AP Java Subset
• For the AP-A course, you need to be able to implement the Comparable interface
• It only has one method– Int compareTo( Object obj)
![Page 47: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/47.jpg)
Agenda 2-24-06
• Finish 5.2 - 5.6 - 5.7 Be ready to show me by 8:45
• Test Next Tuesday – Similar format to the quizzes
• Multiple Choice
• Trace the code
• Write a method
• Notes- Power Point posted online
![Page 48: AP Computer Science A Jacobson Week 1 Second Semester.](https://reader035.fdocuments.in/reader035/viewer/2022062421/56649e585503460f94b51563/html5/thumbnails/48.jpg)
Test Topics
• Chapter 4
• Chapter 5 up to 5.4– Example of Parameter Passing
• Objects vs. Primitive types
– Example of implementing the Comparable interface