Skip to content

FRC-Processing-Lessons/Lesson_4_Bounce

Repository files navigation

Lesson_4_Bounce

Setup

Clone this repository:

git clone https://github.com/FRC-Processing-Lessons/Lesson_4_Bounce.git

Navigate to your repository folder, and open the following file in Processing:

Lesson_4_Bounce.pde

In case you can't find processing, make sure that after unarchiving the application, setup shortcuts for the executable file.

Series Overview

This is the third of a series of lessons on programming in Java for the FIRST Robotics Competition. It is designed for novice programmers, and can act as a precursor programming sequence to learning FRC-Java. We will introduce:

  1. Introduction to programming
  2. Data abstraction
  3. Procedure invocations
  4. Procedure definitions <--- We are here!
  5. Looped behavior
  6. Field scope
  7. Class definitions
  8. Object instantiations
  9. Instance methods
  10. Static methods

This series will be taught using the Processing framework for easy visualization.

Lesson Overview

Once the repository is cloned and the file is open in Processing, students should see 5 tasks listed. Throughout the course of this lesson, students...

Preamble:

For this lesson, we'll be a lot less verbose than in previous directions. Your objective is to learn how to add functionality to objects by adding methods to make them bounce!

Tasks:

  1. There is a new interface defined called Bounceable. Your Circle and Rectangle classes implement this interface, but it's not done correctly. As such, there is an error on those pages. Find the error and add a method that to each of those classes that will fix the error. (Hint: The interface Bounceable requires a bounce() method be defined.)
  2. Add code to bounce to allow the object to bounce according to which axis needs bouncing. For example, if your shape hits the bottom edge, it should bounce the y-axis.
  3. Add code to move to determine IF you need to bounce the object. (Hint: Look up if statements!)
  4. Make sure that you have 2 objects bouncing, at the very least.
  5. This is a hard assignment. Work together as a group!