Mr. Rogers AP Computer Science A - Third Quarter Objectives |
Syllabus | 1st Quarter | 2nd Quarter | 3rd Quarter | 4th Quarter |
|
Major Software Project
Chapters 15, 16, 17, Basic GUI Information (scroll down to appendix D)
Essential Question: How can we create a user-friendly, event-driven program? |
|
||
|
|
|
|
||
|
|
Programming assignments (summative/formative assessment):
1. Modify NewGuiGraphicsDemo as follows:
Add one or more bouncing objects.
Modify the program so that the background changes color when the start button is activated and the color changes back when the reset button is activated.
Add a slider that adjusts bounce speed to the South Control Panel.
Add a menu item that changes the dot size and contains a radio button group with the following options: small, medium, and large.
Make a unique event driven modification of your choice.
2.
Essential Question: How does OOP development using Java compare with the process of writing a book using English? |
Chapter 11: Class Hierarchies and Interfaces
Relevance: Class Hierarchies and Interfaces make it easier to organize and manage the creation and maintenance of large software projects similar to the way the table of contents, chapters, and appendices help organize books.
Name 2 reasons why duplicate code is a bad idea. (wasteful, hard to maintain)
Explain the purpose of having a hierarchy of classes (inheritance) and how it helps facilitate functional decomposition ( breaking down an overwhelmingly complex task into smaller doable tasks).
Define polymorphism and explain why it is useful (page 293).Polymorphism is the situation in which an inherited method can have more than one meaning.
Example:
overriding of methods: the code within a method inherited from a super class can be altered by recreating the method in the subclass. However, this only alters the code when the method is called by an instance of the subclass. When the method is called by an instance of the super class, the original unaltered code is run.NOT generally considered polymorphism--overloading of methods: these are methods in the same class that have the same name but different parameters.
- Example declaration:
- public abstract int tax(); // Note that there is no code, not even brackets.
- Example declaration:
- public abstract class People {
- . . .
- }
- Example declaration:
- public interface Career {
- . . .
- }
Has no abstract methods.
Be aware that all classes automatically extend the class Object.
interface -- contains only abstract methods, no instances of the interface are allowed and it has no constructor. Fields in an interface can only be symbolic constants.
abstract class -- contains one or more abstract methods. no instances of the abstract class are allowed
concrete class -- contains no abstract methods. Instances of the concrete class are allowed
Be aware that Java does not allow the creation of objects (instances) of an abstract class or an interface.
- A class can only extend one class but can implement multiple interfaces.
- Interfaces make code readable and uniform by standardizing the labeling of procedures (methods).
Be aware that if a class implements an interface (and it can implement as many as it wants), it must supply all the methods specified in the interface.
To initialize fields inside a super class:
- a superclass's constructors must be used to initialize private fields
- a superclass's constructors can be called inside the subclasses constructor using super (<appropriate arguments>);
- if a superclass constructor is not called from the sub class constructor, the no-arguments-constructor of the superclass is run (see below). If a no-arguments-constructor doesn't exist, a compiling error results.
Explain how polymorphism applies to interfaces.
Homefun (summative/formative assessment): Exercises 1-5
Programming assignments:
1. Pumpkin Farm Simulation: Create the following:
Squash class -- has a protected weight field and a grow method that adds a random double between zero and 10 to weight each time it's run (representing one week's growth).
Pumpkin class -- inherits the Squash class
Crop interface -- contains 1 abstract method called yield ( ) that returns a double representing the yeild from a crop.
PumpkinFarm class -- implements Crop, creates a field with an array of ten pumpkin objects (starting weight = 0) and grows them for 10 weeks. Outputs the total weight of pumpkins using the yield method.
2. Modify NewGuiGraphicsDemo to act as a diffusion simulation as follows:
Add a Dot class that defines the characteristics of a dot. Include public fields for the x and y coordinates, x and y velocities, and the color of the dot (called dotColor).This class should have 2 constructers. The first will have no parameters or code in it (it's required for subclasses). The second will have an Color parameter that sets a value for dotColor and an int parameter that sets a value for x-coordinate. All other initial values of fields will be set using appropriately sized random number generators. Remember, the x-coordinate will locate the dot on the correct side of the screen.
Add a RedDot and a BlueDot class. Have both extend the Dot Class. Both classes will set the respective color of the dot (red or blue) and set the correct screen side by calling the super class constructor in their constructor. To see how this is done, see the InheritanceInterfaceDemo code.
Create an ArrayList of red dots that start on the left side and an ArrayList of blue dots that start on the right side. The 2 ArrayLists will be created in the GraphicsDisplay class (see the example code at right).
Create a vertical barrier in the middle of the screen. The barrier is to have a hole in it so that dots can bounce through the hole but not through the barrier. This code will also reside in the GraphicsDisplay class
Summative Assessment: Test Chap 11 Objectives 1-15
Essential Question: How can we search and sort millions of volatile pieces of similar information without having to create millions of lines of code? |
Chapter 13: Searching Sorting and Other Array Elements
Relevance: Searching and sorting are the two of the most common types of algorithms for manipulating data records..
Assignment: Read Dragons and Binary Search
Given a set of data records be able to pick the above search method which will be likely to run the fastest.
Write the code which can find the largest or smallest element in an array.
- Initialize an int variable n to the largest index in the array.
- Find the biggest in the first (n) elements array.
- Swap the biggest for the element n.
- Perform n - -
- Repeat while n >= 1.
- selection sort -- O(n2), Assignmet: read Sorting During the Flu Outbreak: The Reality of Sorting Small Sets
- insertion sort -- O(n2),but if sorted O(n), Assignment: read Why Tailors Use Insertion Sort
- merge sort -- O(nlogn), Assignment: read Merge Sort and Lines of Kindergarteners
Hypothetical Time Required for Sorting Objects vs Big-O Notation
Items to sort
2 10 100 O(n) 1 5 50 O(n2) 1 25 2500 O(nlogn) 1 17 332
Given a set of data records be able to pick the above sort method which will be likely to run the fastest.
Name the search and sort algorithms which could be categorized as divide and conquer techniques. binary search, merge sort
Be aware of the methods associated with the Array class.
Be as one with chapter 3 of Gridworld.
Create a program with an integer array containing 20 random numbers. Use code to initialized the array with random integers from 0 to 100. Using command line input search the array for a specific number. Output the entire array, the highest value, the lowest value, and the index number where the number you searched for was found or a statement that the number was not found.
Add a selection sort (write the code, see p. 332) to the above and output the sorted array by creating a Sort class with selection sort method in it.
Add the code for a binary search which will then search for the element specified earlier in command line input and output the index where it exists. If the value is not found it will output "Not found". Configure the program to find multiple instances of the the search target.
Test: Chap 13 Objectives 1-6
Essential Question: How does Java allow a program to read and write to the hard drive? |
Chapter 14: Streams and Files
Note: Chapters 14 covers items not typically not found on the AP exam but will be useful in creating your personal project.
State the 2 major categories of files.
binary
ASCII or Unicode (text)
Describe how the lines in text files are ended ( CR+LF).
Be as one with the following vocabulary: buffer, stream, random-access file.
Be aware that a stream can be opened for input or output but not both at the same time.
Be aware that a random access file can start reading or writing at any point in the file. It can be opened for both reading and writing at the same.
Be aware that text files tend to have different lengths and are usually treated as streams while binary files of fixed length are treated as random-access files.
Note: Chapters 15, 16, and 17 deal with graphics, GUI components, mouse, keyboard, sounds and images. These items are typically not found on the AP exam but will be useful in creating your personal project.
Assignment: Continue working on your personal project.