Title: AP Computer Science A
1AP Computer Science A
- Jacobson
- Week 1
- Second Semester
2Agenda
- First Semester- Reflections
- Book Check (For Real)
- Marine Biology Case Study
- Chapter 1
- Homework
- First Semester Grades
3Objectives 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.
4Reflection 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.
5Share with Class
6Mr. Jacobsons Reflections
- Positives
- Hard work- Diligence
- Problem solving skills are starting to show
- Semester Project
7Mr. Jacobsons Reflections
8Mr. Jacobsons 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
9Mr. Jacobsons Reflections
- Places for Change
- More responsive assessments
- More student participation
- Less distractions
10Book Check
- Collect all Simply Java
- Check the number of the other textbook
11Marine 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
12Marine Biology Case Study
13Warm up
- Assume that x is an initialized int variable.
The code segment - if (x5) x2
- if (x10) x 0
- Is equivalent to which of the following code
segments? - x 0
- if (x 5) x 0
- if (x 5) x 2
- if (x 5) x 0 else x 2
- if ( x 5) x 2 else if (x 10) x 0
14Agenda
- Finish Chapter 1 Case Study
- Work together
- Class discussion
- Truth Tables
15Case Study
16(No Transcript)
17Objective-Truth tables
- Today you will make a truth table for a complex
logical expression and apply that to java
programming.
18Truth 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
19Simple Comparisons
- ( total sum )
- (x
- ( 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
20More Complex- Truth tables can help
- ( (X 20) (X
- statements are true only if both parts are
true
A B A B T T T T F F F T F
21More Complex- Truth tables can help
- ( (X 20) (X
- 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
22More Complex- Truth tables can help
A B !B A !B T T F F T F T
T F T F F F F T F
23Make 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
24Equivalent 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
25HW
- 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
26Warm 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
27Warm Up
- Consider the following two methods
- public static void printStuff(int x)
- int y1
- while (y
- 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 ? - 1 2 1 1 1 x0
- 1 2 1 1 x0
- 1 2 2 x0
- 1 2 4 x8
- 1 2 x8
28Warm up picture
printStuff (int x) x y
Mystery x
OUTPUT
29Agenda
- 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
30HW- 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)
31Agenda
- 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
32Study Sessions
33Tracing the Code
- Where were we last time?
- Parameter Passing Example
- Pages 253-255
34Agenda 2-17-06
- Collect HW
- Programming Projects p.294 5.1
- Finish the Chapter
- interface
- Making one
- Using one
35Agenda 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
36Time to Imagine
- Imagine a bunch of 4 year olds in the middle of
a basketball court
37Time to Imagine
- And the adult in charge says OK, RUN!!!
- What will happen?
38Time to Imagine
- Now imagine the same set up with the following
exception
39Time to Imagine
- A series of walls are put up. What will the kids
do in this case?
40In 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.
41interface - 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
42More 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.
43Example
- 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?
44Shapes 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()
45Shapes 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
46AP 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)
47Agenda 2-24-06
- Finish 5.2 - 5.6 - 5.7 Be ready to show me by
845 - Test Next Tuesday
- Similar format to the quizzes
- Multiple Choice
- Trace the code
- Write a method
- Notes- Power Point posted online
48Test Topics
- Chapter 4
- Chapter 5 up to 5.4
- Example of Parameter Passing
- Objects vs. Primitive types
- Example of implementing the Comparable interface