Object-Oriented-Programming-22-23-Resources
Object-Oriented-Programming-22-23-Resources
Welcome to CSA
Resources
Unit 1 Lesson 1
Which one has the most room for you to grow? Why?
Which one has the most room for you to grow? Why?
Object-Oriented Programming ('22-'23)
Java Lab
Resources
CSA Unit 1 Guide
syntax error
Reflection
What did you learn from your classmates today?
How do the ideas and thoughts shared in class contribute to your identity as a software engineer?
CSA Unit 1 Guide
In your own words describe object-oriented Follow along with the video, and write your own
programming. class here.
class
package
CSA Unit 1 Guide
U
M
L
How is memory in a computer like the land a What is the relationship between a Painter object
house is built on? and the Painter class?
state
Reflection
Curiosity is one of our four qualities of a software engineer. How did you engage your curiosity throughout
this class period?
CSA Unit 1 Guide
Write your instructions for the delivery driver here. Write your instructions for the bus driver here.
● ●
● ●
What do you think would happen if we tried to call one of these methods without first instantiating a Painter
object?
Reflection
How is giving directions to a computer similar to giving directions to a person? How is it different?
CSA Unit 1 Guide
boolean
Reflection
What parts of this lesson made you feel confident in your work? What would you like to practice some more?
CSA Unit 1 Guide
Lesson 6: PainterPlus
Managing Social Media Apps
You are designing a program to keep track of the different social media services that you use. You create a
class called SocialMedia to represent all service media accounts with the attributes username and followers
as well as a method to postMessage.
Does this SocialMedia class represent all the types of social media accounts you use?
What other types of social media services are there? What are the similarities and differences between these
types of social media services?
CSA Unit 1 Guide
Video: Inheritance P
A
What is the relationship between Annotate this code segment using the vocabulary from this I
ClubOfficer and ClubMember? video. N
T
public class ClubOfficer extends ClubMember {
E
R
P
L
U
Painter and PainterPlus UML Diagram S
Draw your UML diagram for the PainterPlus class below.
PainterPlus Painter U
M
xLocation L
yLocation
direction D
remainingPaint I
A
void turnLeft() boolean isFacingNorth() G
void move() boolean isFacingEast() R
void paint(String color) boolean isFacingSouth() A
void scrapePaint() boolean isFacingWest() M
int getMyPaint() String getColor()
void takePaint() int getX()
boolean isOnPaint() int getY()
boolean isOnBucket() String getDirection()
boolean hasPaint() void setPaint(int paint)
boolean canMove()
boolean canMove(String direction)
Reflection
Think of a board game, card game, or video game that you play. How could an element of your game be
represented by a class? What elements could be represented with subclasses?
CSA Unit 1 Guide
Should these additional attributes and behaviors be accessible by the Bird class?
method signature
Writing a Method
What are the similarities and differences between calling methods and writing methods?
CSA Unit 1 Guide
Why would we write a new method in the subclass instead of in the superclass?
What does a PainterPlus object need to do to turn right? What would we write in the body of the
turnRight() method?
Reflection
What errors did you encounter while writing your code today?
● ●
● ●
TAG
Reflection
What is a skill you are currently practicing that you would like feedback on?
CSA Unit 1 Guide
Lesson 9: Loops
Components of an Algorithm
boolean hasPaint()
boolean isFacingNorth()
boolean isFacingEast()
boolean isFacingSouth()
boolean isFacingWest()
What new behaviors could we add to the PainterPlus class using while loops and these new methods?
CSA Unit 1 Guide
control structure
iteration statement
while (myPainterPlus.isFacingWest()) {
myPainterPlus.move();
}
Algorithms
algorithm
Reflection
What errors did you encounter while writing your code?
What is the purpose of the if-else statement? How does the ! operator influence the boolean
statement?
Reflection
Based on the feedback you received in your code review, what is one goal you have for yourself as you write
code in the future?
CSA Unit 1 Guide
When have you encountered How did you find and fix these What tools or strategies would
logic errors in your programs? errors? help find and fix logic errors?
int getMyPaint()
What do you think these methods do? int getX()
int getY()
String getDirection()
How can printing to the console be Write a sample print statement that prints: "Fido's age:"
used as a debugging technique? followed by the age stored in the fido object.
CSA Unit 1 Guide
Reflection
How were you able to use System.out.println() to find and fix errors in your code?
CSA Unit 1 Guide
Algorithm:
Solving Problems
decomposition
Reflection
What parts of this lesson were similar to things you have encountered in your life?
What were you confident about? What would you like to practice more?
CSA Unit 1 Guide
Why should we make a new type of Painter instead of adding methods for
this problem to PainterPlus?
Reflection
What stands out to you about how class hierarchies are used in programs? What makes you wonder?
CSA Unit 1 Guide
Reflection
You are now almost done with your first unit of AP CSA. How has your perspective or understanding of Java
been changed, challenged, reinforced, or deepened as a result of this course?
CSA Unit 1 Guide
public class Pyramid { What parts of this open source code look familiar?
public static void main(String args[]) {
int i = 0;
while (i <= 5) {
int r = 0;
while (r < i) {
System.out.print("*");
System.out.println();
}
}
}
}
Reflection
What three big ideas are you most confident in explaining?
What two ideas might you want to revisit in more depth while working on your Asphalt Art Project?
Name(s)__________________________________________ Period ______ Date ___________________
Response:
AP Exam Prep
Response:
Extra Practice
Do This: Fix the syntax errors by writing the correct code in the "Correct" column.
Incorrect Correct
myPainter.move();
CSA 1
Object-Oriented Programming ('22-'23)
The Neighborhood
Resources
Name(s)__________________________________________ Period ______ Date ___________________
Question: Which of the following are attributes that a Student object might have?
I. name
II. grade
III. goToSleep
A. I only
B. II only
C. I and II
D. II and III
E. I, II, and III
Response:
AP Exam Prep
Question: A student creates a Painter class. The object art will be declared as a type Painter. Which of
the following statements is true?
Response:
Extra Practice
Give your own example of a class and identify what attributes and behaviors the class would have. Then give
some examples of objects that you could create from the class.
CSA 1
Object-Oriented Programming ('22-'23)
Navigating and Painting
Resources
Name(s)__________________________________________ Period ______ Date ___________________
Question: What lines of code should replace /* missing code */ to produce the final state of the Painter
object and The Neighborhood shown here?
Start End
myPainter.turnLeft();
myPainter.turnLeft();
myPainter.turnLeft();
myPainter.move();
myPainter.takePaint();
myPainter.takePaint();
myPainter.takePaint();
myPainter.paint("white");
myPainter.move();
/* missing code*/
myPainter.paint("white");
myPainter.turnLeft();
myPainter.turnLeft();
myPainter.turnLeft();
myPainter.move();
}
}
CSA 1
a. myPainter.paint("white");
b. myPainter.paint("white");
myPainter.turnLeft();
c. myPainter.turnLeft();
myPainter.paint("white");
d. myPainter.paint("white");
myPainter.turnLeft();
myPainter.move();
e. No code is needed.
Response:
AP Exam Prep
Question: Given a Painter named jackie, which of the following lines of code will cause a syntax error?
I. jackie.move();
II. jackie.turnleft();
III. jackie.paint("red");
a. I only
b. II only
c. III only
d. I and II only
e. II and III only
Response:
Extra Practice
Do This: For each line of code, identify the name of the Painter and the name of the method.
picasso.takePaint();
basquiat.move();
dali.turnLeft();
frida.paint("red");
CSA 2
Object-Oriented Programming ('22-'23)
One-Way Selection Statements
Resources
Name(s)__________________________________________ Period ______ Date ___________________
Question: What line of code should replace /* missing code */ so that the code compiles?
I. canMove()
II. jes.canMove()
III. canMove(jes)
A. I only
B. II only
C. III only
D. II and III
E. I, II, and III
Response:
AP Exam Prep
Do This: The code snippet below has five syntax errors. Identify and fix these errors by:
● Circling or highlighting the error in the original code.
● Rewriting the code with all errors debugged in the Debugged Code column.
Response:
Original Code Debugged Code
if (deshaun.isOnPaint) {
deshaun.scrapePaint;
deshaun.move();
}
deshaun.Move();
CSA 1
Extra Practice
Do This: Create a diagram to identify the similarities and differences between the methods you learned today
that returned a boolean value (isOnPaint(), isOnBucket(), and canMove()) and the methods you learned
yesterday that allowed you to move and work with paint (move(), turnLeft(), paint(), and takePaint()).
CSA 2
Object-Oriented Programming ('22-'23)
PainterPlus
Resources
Name(s)__________________________________________ Period ______ Date ___________________
Question: Which of the following combinations of superclass and subclass are correct examples of
inheritance?
a. I only
b. II only
c. III only
d. I and II only
e. I and III only
Response:
AP Exam Prep
Question: Think of an example of inheritance in your own life. What is the superclass? What is the subclass?
Response:
Extra Practice
Do This: Building off of your superclass and subclass from the above AP Exam Prep question:
1. Write the header (which starts with public class…) for your superclass.
CSA 1
Object-Oriented Programming ('22-'23)
Writing Methods
Resources
Name(s)__________________________________________ Period ______ Date ___________________
public ClubMember() {
Which of the following correctly implements the subclass ClubSponsor with a method called donate()?
public ClubSponsor {
super();
}
public donate {
}
public donate {
}
}
public ClubSponsor() {
super();
}
CSA 1
D. public class ClubSponsor extends ClubMember {
public ClubSponsor() {
super();
}
public donate() {
}
public ClubSponsor() {
donate();
}
Response:
AP Exam Prep
Question: The PainterPlus class is shown below. You will write one method of the PainterPlus class.
// turnRight
public void turnRight() {
turnLeft();
turnLeft();
turnLeft();
}
}
Response:
CSA 2
Extra Practice
Do This: Adding more methods to our classes allows us to add more functionality and behaviors to objects.
Let’s add more functionality to the PainterPlus class:
1. Make a list of three methods that would be useful to add to the PainterPlus class.
2. For each method in your list, do the following:
a. Give it a name.
b. Write a description.
3. Write a method in Java for one of the three methods you described.
CSA 3
Object-Oriented Programming ('22-'23)
Code Reviews
Resources
Name(s)__________________________________________ Period ______ Date ___________________
Question: Consider the following code segment. Which of the following would be the best example of good
feedback to give the programmer?
A. "Please indent."
B. "Nice job!"
C. "Nice job! I wonder if the code would be easier to read if there was indentation."
D. "Please indent and use better variable names."
E. "Nice job! I wonder if the code would be easier to read if there was indentation. Also better variable
names might make the code more readable."
Response:
AP Exam Prep
Question: What does TAG stand for, and how can it be used to improve code reviews?
Response:
CSA 1
Extra Practice
Do This: Write a note to your group about how you like to receive feedback. You may choose to share:
CSA 2
How to Conduct a Code Review
● Fewer bugs. Code reviews decrease the amount of bugs in a program before it reaches the user.
● Knowledge sharing. Software development teams learn from each other by reviewing each other's code.
● Code quality. Code reviews ensure the readability, efficiency, and maintainability of the program.
● Better performance. Code reviews help identify any performance issues in the program.
You will use code reviews in this course to strengthen your programming and collaboration skills. You will receive many
opportunities throughout the curriculum to review your peers' code and give meaningful feedback.
How to Request Feedback
To request feedback on their code from a group, select the Start Code Review button in the Review tab. This initiates
a code review and makes your project visible to your peers
You are unable to edit their code while it is open for review. Once you are finished receiving feedback, you can
select the Close Review button and resume editing your code.
When requesting feedback, it is also helpful to provide a description of the goals and intended outcome of the program
and include any additional relevant information. You can ask the reviewer to perform specific tasks or answer specific
questions, such as:
2
How to Give Feedback
In the Review tab, choose a peer from the Review a classmate’s project… dropdown. If a peer has requested
feedback, their name will appear in the dropdown. You can only review peers that are within your code review group.
When you are finished providing feedback, select the Return to my project button. The requesting student can then
review the feedback and make any updates to their code.
Feedback should be helpful for the developer and focused on the program itself rather than the developer or their
abilities. When giving feedback:
● Be kind.
● Make sure your feedback is linked to the goals and intended outcome of the program.
● Balance giving explicit instructions with simply pointing out problems you find and letting the developer decide
how to address them.
● Encourage the developer to simplify code or add comments instead of just explaining it to you.
3
Guiding Questions
The following guiding questions are helpful questions to ask yourself while reviewing code. Not all questions will be
relevant for every type of project.
● Would another developer be able to easily understand and use this code when they come across it in the
future?
● Did the developer choose clear names for variables, classes, methods, etc.?
4
Using TAG to Give Feedback
The following sentence starters will help you structure feedback. Not all sentence starters will be relevant for every type
of project.
T
● I really like this part of your code because . . .
● This is a high-quality program because . . .
● One thing you did really well is . . . because . . .
Tell them something you
like about their code ● You put a lot of thought and effort into . . .
● I'm really impressed with . . . because . . .
A
● How will you . . . ?
● I am wondering . . .
● I don't understand how . . . does / addresses . . .
Ask them something
about the code ● Did you consider . . . ?
● What is the program supposed to do if . . . happens?
● Where is . . . ?
● When does . . . ?
G ●
●
Perhaps you should add / remove / replace . . .
To make your program better, I would suggest . . .
Give a suggestion for ● I am confused by . . .
improvement
● You might consider . . .
● Do you think you should . . . ?
● Don't forget to . . .
● One minor mistake is . . .
5
Object-Oriented Programming ('22-'23)
Loops
Resources
Unit 1 Lesson 9
Writing Algorithms
An algorithm is a set of instructions to solve a problem or accomplish a task. Algorithms are often written in
pseudocode, a plain language description of the steps in an algorithm.
Example: Navigate a PainterPlus object to an obstacle and paint the space in front of the obstacle white.
None
the PainterPlus object is in front of an obstacle and has painted the space in front
of it
while (myPainterPlus.canMove()) {
myPainterPlus.move();
}
myPainterPlus.paint(“white”);
takeAllPaint()
The takeAllPaint() method should take all paint from a paint bucket while it still has paint.
Painter is on a bucket with 5 units of paint. There is no more paint in the bucket.
2
Step 2: Design the algorithm.
Write your algorithm in pseudocode for the takeAllPaint() method.
3
paintLine()
The paintLine() method should paint in a horizontal or vertical line using a specified color as long as there are no
obstacles.
4
Step 2: Design the algorithm.
Write your algorithm in pseudocode for the paintLine() method.
5
Name(s)__________________________________________ Period ______ Date ___________________
Question: Which of the following is ALWAYS true for BOTH while loops and if statements?
Response:
AP Exam Prep
Question: Consider the code below. How many times will the line labeled // move run?
while (myPainterPlus.canMove()) {
myPainterPlus.move(); // move
}
a) 0 times
b) 1 times
c) 3 times
d) 8 times
Response:
CSA 1
Extra Practice
Do This: You’ve learned a lot of code and vocabulary so far. How are you feeling about AP Computer Science
A? What strategies did you use so far to be successful with the material? How can you continue to use these
strategies throughout the course of the class?
CSA 2
Object-Oriented Programming ('22-'23)
Two-Way Selection Statements
Resources
Unit 1 Lesson 10
moveOrTakePaint()
While a PainterPlus object can move forward, the moveOrTakePaint() method should move forward if a
PainterPlus object is not on a paint bucket. Otherwise, it takes all of the paint from the paint bucket.
2
moveSouth()
The moveSouth() method should move forward while a PainterPlus object can move south. If the PainterPlus
object is not facing south, it should turn right. Otherwise, it moves forward.
3
Step 2: Design the algorithm.
Write your algorithm in pseudocode for the moveSouth() method.
4
Name(s)__________________________________________ Period ______ Date ___________________
Question: Where will the Painter be located after this code segment executes?
if (myPainter.canMove()) {
myPainter.move();
myPainter.turnLeft();
}
else {
myPainter.turnLeft();
}
A. B. C.
Response:
CSA 1
AP Exam Prep
Question: Improve the code segment below by simplifying the two if statements into an if-else statement.
if (myPainter.isOnPaint()) {
myPainter.turnLeft();
}
if (!myPainter.isOnPaint()) {
myPainter.move();
}
CSA 2
Extra Practice
Do This: Using while loops and if-else statements, navigate the Painter to the end state shown below.
Start End
CSA 3
Object-Oriented Programming ('22-'23)
Debugging Strategies
Resources
Name(s)__________________________________________ Period ______ Date ___________________
Question: The following code segment has a logic error, but the programmer is having trouble finding the
error. The programmer wanted the Painter object to paint a line to the east, but it keeps going west.
2 myPainterPlus.move();
3 myPainterPlus.move();
4 myPainterPlus.move();
5 myPainterPlus.move();
6 myPainterPlus.turnRight();
7 myPainterPlus.move();
8 myPainterPlus.takeAllPaint();
9 myPainterPlus.turnRight();
10 myPainterPlus.paintLine("green");
A. myPainterPlus.canMove("east");
B. myPainterPlus.getX();
C. myPainterPlus.getMyPaint();
D. myPainterPlus.isOnBucket();
E. myPainterPlus.getDirection();
Response:
CSA 1
AP Exam Prep
Question: Given a Painter object named myPainter, what is printed when the following code is run?
Response:
Extra Practice
Do This: Think of the error messages and unexpected results we've put on the Debugging Wall. How could
printing help in those situations?
CSA 2
Object-Oriented Programming ('22-'23)
Decomposition and Design
Resources
Unit 1 Lesson 12
Decomposition
Sometimes, problems are so big that we need to break them down into manageable tasks first. This process is called
decomposition. Consider the following problem to paint an alternating checkerboard pattern in The Neighborhood.
To solve this problem, two different programmers wrote the following pseudocode.
Pseudocode A Pseudocode B
while the Painter can move south while the Painter can move
while the Painter can move east if the Painter is facing east
paint white paint white
move forward twice
if the Painter cannot move forward
move to the next row and face west turn right
move forward
while the Painter can move west turn right
paint red else
move forward twice move forward
move to the next row and face east if the Painter is facing west
paint red
● moveFast() – move forward and collect paint as long as there are no obstacles
You may also write additional algorithms for components of the problem as needed.
2
Using Decomposition: Choice B
You have been asked to paint dashed lines between the lanes of traffic.
● moveFast() – move forward and collect paint as long as there are no obstacles
● paintDashes() – paint lines that are two spaces long with an empty space in between from one end to the
other as long as there are no obstacles
You may also write additional algorithms for components of the problem as needed.
3
Using Decomposition: Choice C
You have been asked to paint a border around the food truck so it has a designated parking space. But someone left
paint buckets all over The Neighborhood, and you need to collect all of the paint as well.
● paintFast() – move forward, paint, and collect paint as long as there are no obstacles
You may also write additional algorithms for components of the problem as needed.
4
Using Decomposition: Choice D
Navigate and paint the path to the traffic cone.
● paintFastAndTurn() – move forward, paint, and collect paint as long as there are no obstacles and turn if
unable to move in the direction it is facing
● makeTurn() – turn left or right based on which direction a PainterPlus object is able to move
You may also write additional algorithms for components of the problem as needed.
5
Name(s)__________________________________________ Period ______ Date ___________________
Question: Describe how you helped the Painter break down a big problem into a smaller problem today.
How did that affect how you wrote your code?
Response:
AP Exam Prep
Question: You have been asked to paint a crosswalk to make The Neighborhood safer for pedestrians.
Which algorithms make the MOST sense to write in order to decompose the problem?
I. paintDiagonal
II. paintFast
III. turnAround
A. I only
B. II only
C. III only
D. I and II
E. I, II, and III
Response:
CSA 1
Extra Practice
Do This: Write the pseudocode for paintDiagonal to decompose the AP Exam Prep problem.
CSA 2
Object-Oriented Programming ('22-'23)
PatternPainter
Resources
Name(s)__________________________________________ Period ______ Date ___________________
Question: Consider the following superclass and subclass. Which of the following new subclasses would be
appropriate to add to the hierarchy? Select two answers.
A. Mexico
B. Canada
C. Texas
D. California
E. Asia
Response:
AP Exam Prep
Question: When designing classes, what are some of the reasons to use inheritance?
Response:
CSA 1
Extra Practice
Do This: Adding more methods to our classes allows us to add more functionality and behaviors to objects.
Let’s add more functionality to the PatternPainter class:
1. Make a list of three pattern designs that would be useful to add to the PatternPainter class.
2. For each method in your list, do the following:
a. Give it a name.
b. Give it a description.
3. Write a method in Java for one of the three methods you described. Before writing the method, use
the blank grid below to design your pattern.
Pattern 1:
Pattern 2:
Pattern 3:
CSA 2
Object-Oriented Programming ('22-'23)
BackgroundPainter
Resources
Name(s)__________________________________________ Period ______ Date ___________________
Question: Which of the following class headers represents the most appropriate inheritance relationship?
Response:
AP Exam Prep
Extending a subclass from a superclass creates an "is-a" relationship between a subclass and a superclass.
Explain this statement in your own words. Use enough detail that someone unfamiliar with the concept would
be able to understand.
Response:
CSA 1
Extra Practice
Just like the PatternPainter and BackgroundPainter working together to paint an entire scene, programs
often work together to accomplish parts of a larger task. Think of a task that you do often that requires at
least three different but related objects to complete. Once you have an idea, create an inheritance hierarchy
flowchart. Next, describe the job done by each object and how they work together to complete the task.
Inheritance Hierarchy
Task Description
CSA 2
Object-Oriented Programming ('22-'23)
Open Source Code
Resources
Unit 1 Lesson 15
Directions
Choose one of the open source code examples to review.
Begin by reading through and tracing the code, then answer the questions and write a short summary of what you think
the code does. As you trace the code, be sure to add notes.
Be sure to identify the line or lines you are describing when responding to the prompts.
Each group should have at least one recorder and one speaker who will share the results.
Harmonica App
The open source code sample below was written for the Harmonica app. This code snippet is used to translate
notations to numerical Harmonica notations.
Code Notes
2 if (mVisible) {
3 hide();
4 }
5 else {
6 show();
7 }
8 }
11 if (actionBar != null) {
12 actionBar.hide();
13 }
14 mControlsView.setVisibility(View.GONE);
15 mVisible = false;
2
Evernote App
The open source code sample below was written for the Evernote app. This code snippet is used to write notes.
Code Notes
4 super.onCreate();
5 initializeInjector();
6 buildEverNoteSession();
7 }
9 EvernoteSession.EvernoteService service;
10 if (BuildConfig.DEBUG)
service =
11
EvernoteSession.EvernoteService.SANDBOX;
12 else
service = new
13
EvernoteSession.Builder(this)
14 .setEvernoteService(service)
15 .setSupportAppLinkedNotebooks(false)
.build(BuildConfig.EVER_NOTE_KEY,
16
BuildConfig.EVER_NOTE_SECRET)
17 .asSingleton();
18 }
3
Minecraft's Brigadier
The open source code sample below was written for Minecraft’s Brigadier. This code snippet is used to allow single
quotes in strings for the Brigadier command parser and dispatcher.
Code Notes
4 while (canRead()) {
6 if (escaped) {
if (c == SYNTAX_QUOTE ||
7
c == SYNTAX_ESCAPE) {
if (c == terminator ||
8
c == SYNTAX_ESCAPE) {
9 result.append(c);
10 escaped = false;
11 }
12 else {
13 }
14 else if (c == SYNTAX_ESCAPE) {
15 escaped = true;
16 }
17 else if (c == SYNTAX_QUOTE) {
4
18 }
19 else if (c == terminator) {
20 return result.toString();
21 }
22 else {
23 result.append(c)
24 }
5
Java 2D API
The open source code sample below was written for Java 2D API, which is an advanced graphics package added to
Java. This code snippet shows how Graphics2D adds more uniform support for manipulations of text, line, and
two-dimensional shapes.
Code Notes
3 new Example01();
4 }
5 public Example01() {
6 super("Java 2D Example01");
7 setSize(400,300);
8 setVisible(true);
9 addWindowListener(new WindowAdapter()
11 { dispose(); System.exit(0); }
12 }
13 );
14 }
16 g.setColor(Color.red);
17 g.drawRect(50,50,200,200);
6
18 Graphics2D g2d = (Graphics2D)g;
19 g2d.setColor(Color.blue);
g2d.drawRect(75,75,300,200);
20
21 }
22 }
23 result.append(c)
24 }
7
Exploring Open Source Code
Answer the following prompts about the open source code you chose to review.
If this was your code and you were sending it for a code review, what would you say?
8
Name(s)__________________________________________ Period ______ Date ___________________
Question: Which one of the characteristics of software engineers do you most identify with? Why do you
connect most with that characteristic?
Response:
AP Exam Prep
Question: Someone left a bunch of paint buckets in The Neighborhood and we need the Painter to remove
all the paint in the quickest manner. What control structure do you need to use?
I. if statement
II. if-else statement
III. while loop
a. I only
b. II only
c. III only
d. I and III only
e. I, III, III
Response:
CSA 1
Extra Practice
Do This: Write the definition or draw a picture that best describes the following vocabulary term: conditional,
method, inheritance, and code review.
CSA 2
CSA Unit 1 Study Guide
Objectives
By the end of this unit, students will be able to . . .
● Write clear and readable code using methods, control structures, and comments
Java Concepts
In this unit, students learn about the following concepts . . .
● Java syntax and program formatting ● Using an integrated development environment (IDE)
● Methods that return Boolean values ● Selection (if and if-else) and iteration (while)
Syntax
The following outlines the new syntax that is introduced in each lesson.
myPainter.move();
move()
turnLeft()
takePaint()
paint(String color)
CSA Unit 1 Study Guide
if (condition) {
. . .
}
isOnPaint()
isOnBucket()
canMove()
Lesson 6: PainterPlus
public PainterPlus() {
. . .
}
super();
// A single-line comment
/*
* A multi-line comment
*/
CSA Unit 1 Study Guide
Lesson 9: Loops
while (condition) {
. . .
}
takeAllPaint()
hasPaint()
if (condition) {
. . .
}
else {
. . .
}
!condition
isFacingNorth()
isFacingEast()
isFacingWest()
isFacingSouth()
CSA Unit 1 Study Guide
System.out.print();
System.out.println();
getMyPaint()
getDirection()
getX()
getY()
Object-Oriented Programming ('22-'23)
Asphalt Art Project – Day 1
Resources
Name(s)_______________________________________________ Period ______ Date ___________________
Project Description
You have been chosen to create asphalt art to revitalize The Neighborhood and bring the community together. Cities
implement asphalt art to improve public safety, inspire their residents and visitors, and brighten communities. Your goal
is to improve The Neighborhood using asphalt art with the help of the Painter.
Program Requirements
Use your knowledge of object-oriented programming, algorithms, and decomposition to create asphalt art:
● Create a new subclass – Develop a new class that extends PainterPlus with a one or more additional
behaviors
● Use an existing class – Use PainterPlus, PatternPainter, and/or BackgroundPainter and add additional
behaviors to the class as needed
Project Steps
Day 1 Steps
● Decompose the problem to identify the classes and methods you will need to implement
Day 2 Steps
● Develop your program using the pseudocode you wrote and sketch you created
Day 3 Steps
● Finalize your program using the feedback you received and your self-assessment
8 x 8 Grid
2
12 x 12 Grid
3
16 x 16 Grid
4
32 x 32 Grid
5
Step 2: Create a UML diagram for your new subclass.
6
Step 3: Write pseudocode for the methods you will write.
7
Day 1 Reflection
What did you accomplish today?
Software Engineers
How are you being a problem-solver while you are working on your project?
How are you being creative while you are working on your project?
8
Day 2 Reflection
What did you accomplish today?
9
End of Project Reflection
Describe your project.
What are two things about your project that you are proud of?
Describe something you would improve or do differently if you had an opportunity to change something about
your project.
On a scale of 1 to 4 (4 being the highest), how would you rate your project?
10
Rubric
Existing Class Uses one of the existing Uses one of the existing Uses one of the existing Does not use one of the
classes and its methods to classes and its methods to classes and its methods to existing classes.
create one or more create one or more create one component of
components of their asphalt components of their asphalt their asphalt art design.
art design. art design.
AND
New Subclass Develops a new subclass Develops a new subclass Develops a new subclass Does not develop a new
that extends PainterPlus to that extends PainterPlus in that extends PainterPlus subclass.
provide more than one a new way that provides one but does not create a new
additional behavior that the additional behavior that the behavior for this subclass.
other classes do not have. other classes do not have.
OR
AND AND
Develops a new subclass
Uses the new subclass and Uses the new subclass and that extends PainterPlus to
methods to create one or method to create one or provide a new behavior that
more components of their more components of their the other classes do not
asphalt art design. asphalt art design. have. Does not use the new
subclass and method to
create one or more
components of their asphalt
art design.
11
Object-Oriented Programming ('22-'23)
FRQ Practice
Resources
Unit 1 Lesson 19
SpiralPainter FRQ
Planning
Do This: Annotate the question below using the following format. If you have highlighters or colored pencils, use those
to highlight different sections. If you only have a pencil or pen, follow the instructions to circle, star, box, and underline.
Write the complete SpiralPainter class, including the constructor and any
required methods. Your implementation must meet all specifications and
conform to the example.
Wait for instructions from your teacher before continuing to the next step.
1
Around the World
Travel from station to station. You do not need to complete them in order. At Stations B and C, use the pseudocode table below to create your plan before
writing the actual code on the following page.
Pseudocode
At Stations B and C, follow the instructions and use the manipulatives to create the requested shape. Use the space provided below to write out in pseudocode
the steps you used to create the shape.
draw a square:
paint
move
turn left
paint
move
turn left
paint
move
turn left
paint
move
turn left
2
FRQ Written Response
Write the complete SpiralPainter class here.
STATION A
_____________________
STATION B
_____________________
STATION C
_____________________
3
Reflection
Assess your solution using the Scoring Guidelines and provide brief responses (1-2 sentences each) to the following:
1. For which rows on the Scoring Guidelines did you get the full point?
2. What information did you highlight and/or annotate in the original Free Response Question that helped you get
the full point for these rows?
3. Which rows on the Scoring Guidelines are you still confused about?
4. If you were giving tips to other students completing this FRQ, what advice would you give them?
Rate your experience answering this Free Response Question by coloring in the stars.
I understood what the Free Response Question was asking me to do. ☆☆☆☆☆
I am confident I can tackle similar Free Response Questions. ☆☆☆☆☆
The materials covered in this unit prepared me for this Free Response Question. ☆☆☆☆☆
I'm looking forward to answering more Free Response Questions throughout the course. ☆☆☆☆☆