In this lesson, students are introduced to CodeHS and how Karel the Dog can be given a set of instructions to perform a simple task.
Students will be able to:
Write their first Karel program by typing out all of the Karel commands with proper syntax
Explain how giving commands to a computer is like giving commands to a dog
In this lesson, students learn more about Karel and Karel’s world. Students learn about walls in Karel’s world, the directions Karel can face, and how to identify a location in Karel’s world using streets and avenues. In these exercises, students will begin to see the limitations of Karel’s commands. Students will need to apply Karel’s limited set of commands to new situations. For example, how can we make Karel turn right, even though Karel does not know a turnRight command? wocka wocka
Students will be able to:
This lesson introduces the run method, which is the place where the program starts running. Students will also learn to write full java programs instead of just writing commands. In the the program below, SquareKarel is the name of the class. When we say extend Karel, it means this is a Karel program like the ones we have already written.
public class SquareKarel extends Karel
{
public void run()
{
putBall();
move();
turnLeft();
}
Students will be able to:
In this lesson, students will learn how they can create their own commands for Karel by calling and defining methods. Methods allow programmers to create and reuse new commands that make code more readable and scalable.
Students will be able to:
turnRight()
methodIn this lesson, students learn in more detail about methods, and how they can use methods to break down their programs into smaller pieces and make them easier to understand.
Students will be able to:
In this lesson, students learn about Top Down Design and Decomposition. Top Down Design is the process of breaking down a big problem into smaller parts.
Students will be able to:
In this lesson, students learn how to style their programs by including comments. Comments allow students to leave notes on their program that makes it easier for other to read. Comments are written in plain English.
Commenting Your Code Example:
/*
* multi-line comments
*/
// single line comments
Students will be able to:
In this lesson, students are introduced to Super Karel! Since commands like turnRight()
and turnAround()
are so commonly used, students shouldn’t have to define them in every single program. This is where SuperKarel comes in. SuperKarel is just like Karel, except SuperKarel already knows how to turnRight and turnAround, so students don’t have to define those methods anymore. To use SuperKarel instead of Karel, the class that students write extends SuperKarel instead of Karel:
public class MyProgram extends SuperKarel
{
}
Students will be able to:
In this lesson. students learn how to use for loops in their programs. The for loop allows students to repeat a specific part of code a fixed number of times.
For loops are written like this:
for(int i = 0; i < 4; i++)
{
// Code to be repeated 4 times
}
Students will be able to:
In this lesson, students are introduced a new type of loop: while loops. While loops allow Karel to repeat code while a certain condition is true. While loops allow students to create general solutions to problems that will work on multiple Karel worlds, rather than just one.
Students will be able to…
In this lesson, students learn about the conditional statement “if”. Code within an “if statement” will only execute IF the condition is true.
if (frontIsClear()) {
// Code to be executed only if front is clear
}
Students will be able to:
In this lesson, students learn about an additional control structure, if/else statements. If/else statements let students do one thing if a condition is true, and something else otherwise.
if/else statements are written like this:
if(frontIsClear())
{
// code to execute if front is clear
}
else
{
// code to execute otherwise
}
Students will be able to:
In this lesson, students learn how to combine and incorporate the different control structures they’ve learned to create more complex programs.
Students will be able to:
In this lesson, students get extra practice with control structures. Students will continue to see different ways that the if, if/else, while, and for loops affect their code and what Karel can do.
Students will be able to:
In this lesson, students review how they should indent their code to make it easier to read.
Students will be able to:
In this lesson, students will synthesize all of the skills and concepts learned in the Karel unit to solve increasingly challenging Karel puzzles.
Students will be able to:
In this lesson, students complete a summative assessment of the unit’s learning objectives.
Students will be able to:
This lesson discusses printing a message in Java. Instead of extending Karel, students will now extend Console Program to print to the Console.
public class Welcome extends ConsoleProgram
{
public void run()
{
System.out.println("*insert message here* ");
System.out.println("*insert message here* ");
}
}
Students will be able to:
System.out.print
and System.out.println
Variables allow us to store information such as numbers, words, or true/false expressions. A variable can be thought of as a box that stores information inside. In Java, variables are composed of three things: a name, type, and value.
Students will able to write programs using variables by declaring, initializing and assigning a value to their variable.
In this lesson, students will learn how to retrieve user input by various methods including readLine, readInt, readDouble, and readBoolean. This will allow them to take in data from the user to make our programs work for them.
Students will be able to ask for user input and print out the input in the console program by using readLine, readInt, readDouble, and/or readBoolean.
Arithmetic Expressions allow us to perform mathematical operations within Java. Such expressions can be used for basic math and even more complex algorithms.
Students will able to
This lesson introduces the students to Casting, which is turning something of one type into another type.
Students will be able to…
How do we write code that tells us whether a user is logged in to our program? Booleans are the solution to these questions. A boolean refers to a value that is true or false. Those are the only values of a boolean expression, and these are useful if we want to check if something is true or false.
Students will be able to…
Logical operators allow us to connect or modify Boolean expressions. Three logical operators are the !, ||, && characters.
! = NOT
|| = OR
&& = AND
Logical operators can be used in combination.
With these logical operators, we can construct logical statements such as “I go to sleep when I am tired OR it’s after 9pm”, “I wear flip flops when I am outside AND it is NOT raining”
Students will be able to…
* Describe the meaning and usage of each logical operator: OR (||), AND (&&), and NOT (!)
* Construct logical statements using boolean variables and logical operators
Comparison operators let us compare two values. Using comparison operators in programming is similar to math in that less than <
, greater than >
, less than or equal to <=
, and greater than or equal to >=
are the same. The differences are that operators for equal to are ==
and not equal are !=
. Using comparison operators allows our program to make decisions.
Students will be able to…
* Explain the meaning of each of the comparison operators (<, <=, >, >=, ==, !=)
* Create programs using the comparison operators to compare values
* Predict the boolean result of comparing two values
* Print out the boolean result of comparing values
This lesson explores for loops–why they are useful, and how to use them to repeat code a fixed number of times.
Students will be able to…
* Create for loops to repeat code a fixed number of times
* Explain when a for loop would be a useful tool
* Utilize for loops to write programs that would be difficult / impossible without loops
Just like in Karel, Java has while loops. While loops are a way to repeat a block of code so long as some condition remains true. The condition is written in the form of a boolean expression. As long as the boolean expression remains true, code within the while loop will be executed. The moment that the boolean expression becomes false, code outside of the while loop will be executed; the loop is done.
Students will be able to…
This lesson introduces If Statements. We use if statements to run a segment of code only if some boolean expression first evaluates to true.
Students will be able to…
* Explain the purpose of if statements
* Create their own if statements to selective choose which code is executed in their programs
Infinite loops can occur unintentionally if you are not careful with the conditions of a while loop. In these cases, the infinite loop can cause the program to crash. However, infinite loops can be a very useful tool in programming. If your program needs to repeat a block of code an indefinite number of times, an infinite loop may be the correct approach. Repeating code is helpful, but it’s just as important to be able to stop the loop so that the rest of the program can continue executing. Loops can be stopped using the break statement. When the loop encounters a break statement, it quits running the loop and program flow continues.
Students will be able to…
This lesson introduces Short-Circuit Evaluations. In a Short-Circuit Evaluation, if the result of a Boolean Expression can be determined by the first argument, the second argument is not evaluated.
Students will be able to…
De Morgan?s Laws are rules that show how we can negate ?and?s and ?or?s. Not (A and B) is the same as (not A) or (not B). Similarly, not (A or B) is the same as (not A) and (not B).
Students will be able to…
A String is a sequence of characters. We use Strings to represent full words and sentences. For example, the famous “Hello World” is a String. Some more examples of Strings:
“I am a String. A sequence of characters strung together to form words and/or sentences.”
“CodeHS is the best coding website ever! Everyone loves CodeHS!”
“She sells sea shells by the sea shore.”
“Strings!”
“abcdefghijklmnopqrstuvwxyz”
A String is not a primitive type like int, char, boolean, and double are. Primitive types always start with lowercase letters, but a String starts with a capital letter. This makes it an object.
Students will be able to…
.equals
instead of ==
This lesson is a summative assessment of the unit’s learning objectives.
Assess student achievement of the learning goals of the unit
In this lesson, we learn about methods in Java. Methods allow us to break down our code into reusable parts, avoid using repeated code, and simplify our code.
Students will be able to…
In this lesson, we continue to build our understanding of methods and introduced to parameters. Parameter are inputs to methods.
If methods are boxes, then parameters are inputs to our boxes (what goes inside the box).
Parameters allow us to generalize our methods so that they can solve more than one specific instance of a problem, and instead can solve different versions of the same problem (for example, add 10 to any given number).
Students will be able to…
Think of a method like assigning a task. A return value is giving you the completed work.
This allows you to write methods that do some work for you and send back the result.
Parameters are like inputs into the function, and the return value is output.
Students will be able to…
Comments are an important part of programming style. Programs are usually written by teams of people and maintained for many years. Others need to be able to read your code and understand what is going on.
This lesson introduces Javadocs, which are a standard, agreed upon way of commenting Java code. There is a tool, also called Javadoc, that is able to read Javadoc comments and create clean, clear documentation for your Java programs. Javadoc refers to both the tool and the style of commenting Java code.
From now on, we will be writing Javadoc comments in our programs.
Students will be able to…
Strings come prepackaged with several methods that we can use to help us do cool things! In this lesson we learn how to find and read documentation about how to use the String methods, and we’ll write several programs that call methods on Strings in order to get information about them and manipulate them to form new Strings.
Students will be able to…
In this lesson, we’ll examine the similarities and differences between the String
class and the char
primitive type. Strings are simply sequences of char
s.
We also learn that all char
values have a corresponding int
value. chars are actually stored as numbers! For example, 65 corresponds to ‘A’, 66 corresponds to ‘B’, and so on. We’ll learn about special characters like tabs, quotes, and new lines, and how to store and print these special characters using escape sequences like ‘\n’
Lastly, we learn about the Character class. The Character class provides several useful methods that allow us to manipulate and get information about char values.
Students will be able to…
char
and the class Character
char
values to int
values using castingint
values to char
values using castingchar
valuesAll programs have bugs at some point in the development process. Bugs are ok! They show us exactly where the problems are in our code and give us helpful information so that we can fix these problems.
When there is a bug in your program, Java will actually provide helpful information about where the bug is and what kind of bug is occurring by throwing an Exception. In this lesson we’ll learn about the different kinds of exceptions and what they mean. That way, when we try running our programs and see exceptions, we’ll know how to use that information to debug our programs!
Students will be able to…
We’ve learned about writing our own methods that take in parameters and return return values. We’ve learned about the relationship between Strings and characters. We’ve learned about using the methods of the String class and the Character class. We’ve learned about looping through the characters of a String using a for loop. It’s time to put that all together to write some methods that perform some advanced manipulation of Strings.
Students will be able to…
This lesson is a summative assessment of the unit’s learning objectives.
Assess student achievement of the learning goals of the unit
In this lesson, students learn about the overarching idea of “using a class as a client”. In Java, everything is represented as a class. Classes are a nice way of bundling up functionality. There are classes written for a lot of common needs (such as the String
class and the Character
class), and we can use these classes in our programs.
When someone else creates a class, and you use the functionality of that class, that is called being a client of the class. Users don’t need to know exactly how everything works inside the class, they can just use all the functionality of that class without worrying about the inner workings. For example, you can use the String class to create String objects, and call methods on the objects to get information like the length and the characters at certain indices, without ever looking at the source code for the String class.
Students will be able to:
In this lesson, students will learn about four types of Data Structures. An array is a list of fixed size. An array list is a list of changing size. A 2D-Array is a grid, table, or list of lists. A Hash Map is a Key-Value store.
Students will be able to:
In this lesson, students learn about arrays and make their first arrays. Arrays are one of the main data structures students will need to understand. This lesson introduces the idea, shows students how to create them, and explains how to access data elements to retrieve and update values.
Students will be able to:
In this lesson, students will learn how to traverse an array to access all of the array elements. They will then apply this to real-world activities.
Traversing through an array is a key skill for many programs and as a result, this topic is covered extensively on the AP test.
Students will be able to:
In this lesson, students will learn about ArrayLists and make their own ArrayLists. They will then learn basic methods for ArrayLists to traverse, add, and access the elements in the ArrayList.
While this lesson focuses on ArrayLists, students should be starting to think about how Arrays and ArrayLists are similar and different. This concept is key and will be further explored in the next lesson.
Students will be able to:
In the lesson, students will learn more about the differences between Arrays and ArrayLists and make an ArrayList like class using an Array.
Having learned two different data structures for storing lists, it is only natural to compare and contrast these two structures. Students should come into this lesson with a basic understanding of differences but will develop a deeper understanding through a series of examples and activities.
Students will be able to:
In this lesson, students will learn about the list interface and use this to implement generic formal parameters and create classes that use the List interface.
This lesson is not currently in scope for the AP test, but understanding how to implement and use Java interfaces is a key concept for object-oriented programming.
Students will be able to:
In this lesson, students will learn about 2D arrays. The will also first be exposed to the idea of a nested loop, which will be used to access all the elements in a 2D array.
2D arrays are a key idea for students to grasp. They should spend time to fully understand how the loops execute. They can further supplement these concepts through the Traversing 2D Arrays exercises in the Supplemental Material.
Students will be able to:
In this lesson, students will learn about HashMaps and use them to create solutions to real-world problems. HashMaps offer a different way of storing data in Java using a key/value pair. While this topic is out of scope for the AP test, it is a key data structure used in several programming languages and may make a good topic for after the AP test.
Students will be able to:
In this lesson, students learn how to convert from different number systems to decimal. They also learn more about why binary is used by computers and have an opportunity to write a code that will convert a binary number into a decimal number.
Students will be able to:
In this lesson, students will discuss the ethical issues around how and why data is collected. They will look at the risks to personal privacy when working on computer systems and the internet and discuss how computer programs can have beneficial and/or harmful impacts on personal security. Lastly, the importance that programmers have in terms of safeguarding personal privacy will be considered and emphasized. This lesson corresponds with AP Computer Science A topic 7.7.
Students will be able to:
This lesson is a summative assessment of the unit’s learning objectives.
Assess student achievement of the learning goals of the unit
In this lesson, students learn about creating a large scale project using multiple classes. This lesson walks through the creation of a basic Blackjack game.
Students will be able to:
In this lesson, students will learn about 2D arrays and classes by creating a Battleship program. Through a series of lessons, the game will be broken down into pieces to help implement the solution.
Students will be able to:
In this lesson, students will learn about the basics of algorithms, how they are used in programming, and how algorithms exist in their daily life outside of computer science.
Students will be able to:
In this lesson, students are exposed to the first classic Search algorithm, Linear Search. Students will learn how to code Linear Search, and understand the use and limitation of this algorithm.
Students will be able to:
In this lesson, students learn another algorithm for searching, Binary Search. Students will compare Binary Search to Linear Search, and discuss the reasons why they might need multiple ways to search a list.
Students will be able to:
In this lesson, students learn the basics of sorting. As learned in the previous lesson, Binary Search is a useful search method, but it’s limited by the fact that the lists it searches need to be sorted. In this lesson, students learn that Selection Sort is one way they can sort lists in order to effectively use Binary Search.
Students will be able to:
Student learn a new sorting method, Insertion Sort. As learned in the previous lesson, Binary Search is a useful search method, but it’s limited by the fact that the lists it searches need to be sorted. In this lesson, students learn that Insertion Sort is another way they can sort lists in order to effectively use Binary Search.
Students will be able to:
In this lesson, student learn the concept of recursion. Recursion is the idea that functions can call themselves within the function. This creates an iterative process that allows functions to iterate without using for or while loops, but only conditional statements. Students will practice using recursion, and model it with real world scenarios.
Students will be able to:
Students will learn about a third sorting algorithm, Merge sort. Merge sort uses recursion to break down lists into sublists, and sorts those sublists until the entire list is sorted. Students will compare Merge sort to other sorting methods that they’ve learned.
Students will be able to:
This lesson is a summative assessment of the unit’s learning objectives.
Assess student achievement of the learning goals of the unit.
This lesson is a practice exam that prepares students for the AP Computer Science A exam in May. Like the AP Exam, this lesson consists of a multiple choice test that assesses the learning objectives of the course, as well as free response questions that require students to read a prompt, understand the problem, plan a solution, and write clear and readable code that solves the problem.
Students will be able to…
In this unit, students get to combine all of the new skills they’ve learned to create their own project from scratch!
Congratulations! You have completed the AP Java course! Time to celebrate and reflect on your accomplishments.
Students reflect on what they have learned in the course, celebrate the accomplishment of completing the course, and think about what their next steps are in their computer science education.