AP Computer Science AB Program Assignments

Unit 1: Introduction to Programming

Name of Assignment Description Strands Addressed Comments

Text to Screen

Download the Welcome to CS program from the share folder (take entire program folder) and load and run the welcome.java program. 

  • Modify the System.out.Println Statement to include your name.
  • Add System.out.Println statements to include other welcoming statements to the program

1A, 1B, 1C

Students are downloading entire folders because BlueJ works best if each project is in its own foler.  See education.sudol.com for copies of .java files

Loading and Running a Program

Download the elevator programs from the share folder (take entire program folder) and load and run the ElevatorSystem1.java program. 

1B, 1G, 1I

Students will discuss the creation of the elevator (see elevator powerpoint)

JMBS Part I

Download the Java Marine Biology Simulation from the share folder (take the entire program folder) and load the onefish data file.  See more specific directions on assignment sheet.

1B, 1G, 1I

Discuss the main file of the program – have students read Part I of case study

Drawing a Picture

From the elevator program you downloaded make the following modifications:

  • Change the name of the class inside the file and adjust the file name accordingly
  • Using the documentation for objectDraw create a picture within your window (suggestions: house, flower, your initials, etc.)
  • Comment your code specifically for each new line of code added to the program.
  • Comment the begin and onMouseClick method using javadoc formatting – and use javadoc to create documentation for your program.

1E, 1F, 1G, 1I

Students will be able to match parameter lists to the numbers that are entered into their constructors and other objects.

Mathematics and drawing

From the drawing a picture program make the following modifications:

  • Create a user directed animation by having one of your objects move a set number of pixels every time the mouse is clicked.

1G, 1H, 1I

Students will need to read api documentation to call appropriate methods and pass parameters to objectdraw objects

Various Mathematical Operations

Download the mathPractice program from the folder and write the three methods contained within.  Please note that each of the three methods is a separate program grade

1H

See directions sheet for specific directions on how to create and instance of an object in blueJ and test the methods contained within

Random Numbers

Download the LottoNumbers program from the share folder.  Write the main method for this application that will write the lotto numbers to the screen. (6 numbers between 1 and 52)

 

 

 

Unit II: Input/Output

Note:  Each subsequent assignment will include materials covered in previous chapters, but the standards will not be listed unless they belong to the unit currently being addressed.

Viewing graphics as user IO

Download the BankSplash folder from the share folder.  Create three text fields, one that display the name of the bank when the program is run and two that stay blank until the screen is clicked.  When the screen is clicked the text fields should display the address of the bank.

 

Translating a mouseclick into a request for information.

Reading other IO packages

Create a program that is a simple calculator using the calculator program as found in the share folder.  You will need to read the documentation for the IO class associated with that program.

2B

Students will also work with a variety of the mathematical operators for this program.  A basic swing outline is provided with buttons for each operation and a JOptionPane as an input box for the two values.

Reading IO Packages II

Download the files for the change program (given a number of cents computer the number of quarters, dimes, nickels and pennies needed for the change)

2B

Swing setup created – students need to write code to change the value of a Label on a JFrame (need to use string concatenation to show all answers…)

Reading IO Packages…

Possibility of inserting other program assignments here using different IO systems and practicing mathematical operations

 

 

 

Unit III: Methods

Name Program Assignment

Download the Name program folder from the share file (includes an outline for the name class and a main to test the class once written).  Complete the methods for the name class as specified in the javadoc provided.

3A

Methods can be tested using BlueJ object inspections.

Name Program Part II

Make changes to the main method of the name program to test all of the methods created in the previous assignment.  Also add 5 more names to the list of names in the program.

3A

 

Marine Biology Case Study Part II

Read Part II of the case study and perform exercises appropriate to the material

 

 

Color Constructions

Using the Drawing a Picture program from chapter 1 and the Color Constructions worksheet make color modifications to your objects demonstrating both static and non static method calls.

3B

Color Constructions worksheet will provide examples of creating instances of the Color object vs using the static fields belonging to Color

Prisoner Program

Download the files for the prisoner program and complete the prisoner object as specified by the javadoc information contained within that file.

3A

 

Name Extensions

Implement the comparable object with your name program and use BlueJ’s inspector to test the methods.

 

 

 

Drawing with AWT

 

 

Students will need to write code in 2 different objects – all of which implement a given interface.. (beginning of writing classes from outlines)

Students will have to read documentation of Graphics class

 

Unit IV: Decision Structures

Up/Down Elevators

Download ElevatorSystem1.java and run it (its based on an applet so use appletviewer).  Notice that when you click the mouse the elevator (black rectangle) moves up and keeps going up.  Modify the code for the applet so that you can move the elevator either up or down.  When you click above the elevator it should move up, and when you click below the elevator it should move down.

 

Add an if statement to the onMouseClick method.

Elevator Class

Use the following outline to create an elevator object and modify your elevatorSystem1 code to use that object appropriately.

 

 

Elevator Driver

Modify your Elevator system so that it uses an Elevator object instead of a FilledRect.

 

 

Creating Multiple/Express Elevators

Using your elevatorSystem2 file create two regular elevators and an express elevator for your building.  The express elevator should go directly to the top floor, and when decending should go directly to the bottom floor.

 

 

Payroll Program

Download the employee program folder from the share folder (files to be posted here soon) and complete the methods in employee.java based upon their specifications

 

 

Elevator Buttons

Create a series of buttons for one of your elevators.  The buttons should be representative of the buttons inside the elevator.  Each button should move the elevator to the appropriate floor.

 

 

 

Unit V: Looping Structures 

Counting Sheep

Joe Farmer is having trouble sleeping and wants to count sheep.  Write a program that asks Joe (via a JOptionPane) how many sheep he wishes to count.  Display the sheep randomly around the screen numbered so Joe can count them.  See the sheep class provided as part of this program.

5A, 5B, 5D

Bonus, make the program so that the sheep do not overlap…

Bouncing Ball

The physics department wants to trace the path of a bouncing ball.  The ball bounces according to the following equation: y = h r ^ n where y = current height of bounce, H is the initial height, r is the rebound rate (for our ball it will be ˝) and n is the number of the bounce.  Use the ball class from the share folder to write an objectdraw program that draws the ball at the top of each of its bounces.

5D

Ball class automatically compensates for 0,0 being upper left corner

User Groups

Download the userList program (folder) from the share folder.  This program has the constructor already written for you. It reads a number of user names from a file and stores them in a set.  Use a JOptionPane to ask the user for his username.  Use an iterator to traverse the list and see if the username belongs to the list of users. 

5E, 5F

This program will use a set of usernames

Elevator Floors with Buttons

Modify your multiple elevator program with the following specifications:

  • Each floor should have two buttons (an up button and a down button).
  • When the user clicks on any of these buttons it should call the elevator to that floor.
  • The closest elevator should be the one called to the floor.

The buttons should be stored in an arraylist and an iterator should be used to traverse the list whenever accessing them.

5E, 5F

Iterators used to traverse arraylist – examples shown in class.

Jailer Program

Download the jailer program from the share folder and complete the code for each method as specified in documentation.

5B

Classic “locker” problem – jailer walks down hall turning every other key, then every third key, etc.

Color Sorter

Download the program for colored circles.  Write the code for method redCircles which returns an arraylist of all the red circles contained in the myCircles set.

5E, 5F

Students need to iterate the set and add the values to the arraylist and return it.

Sorting User Names

Add a sortedUserList method to your user groups program.  It should return an arraylist containing a sorted (alphabetically) list of the users of your system.  Use the TestSort driver program to test the results of your coding.  Should print the users in alphabetical order.

5E, 5F

Simple insertion sort…. If(current < lowest && current >= lastSmallest)….

Tollbooth v.7

See http://ww2.sudol.com:81/education/apsummer/colgate02/tollboothSeries.htm for more info

5E, 5F

 

 

 

Unit VI: Introduction to Indexing/ArrayLists

Voice Mail Messages

Download the VoiceMail classes from the shared folder.  The constructor will read the person’s current voice mail from a folder as a series of strings and place them in an array list.  Your job is to print the voice messages to the screen (use system.out.println) Be sure to number each message (just like your answering machine would – “Message 1: ….”)

 

 

XCountry Places

Oh No!! Shanley hit the wrong button on his computer and resorted the places from the recent cross country meet alphabetically.  He needs them resorted according to their places.  Download the cross country program from the share folder and write ShanleySort according to the specifications in the file. 

 

The file requires that students iterate a private variable into a new list and then replace the old list with the new one.

Checkbook v.1

Download the checkbook program from the share folder and implement the methods specified.

 

Add a check to the checkbook, retrieve a check based on the check # (which corresponds to the index)

Class Schedule

Design a class that will be responsible for keeping track of a student’s schedule.  (class names)  The class should include methods that will return an iterator of all the classes, given a period during the day returns the class the student should be in, and a method to make a schedule change.

 

 

Checkbook v.2

Add a method to the checkbook that will return the total amount written in checks.  Add another method that will return the total amount written to a specific person.  See method header on website.

 

Students will need to sum all checks, and then selectively sum the ones that match a string parameter passed to the method.

Grocery Bill

In the grocery folder on the shared folder you will find the following classes:

Grocery: Keeps track of a single item. (read documentation provided in javadoc format for more info)

Reciept: this class has the constructor filled in for you already.  It reads someones grocery order from a file and fills up the array list.

 

Your task is to write the following methods:

totalBill, numberTaxableItems

 

 

 

Unit AP 1:More Algorithms for Collections

Prisoner Simulation Download the code for the prisoner simulation and complete the specified methods. AP1B, AP1D Classic prisoner problem (jailer turns every multiple key) review of arraylist
Timing Comparisons Download the timing program.  Inside this library object are a series of methods that read in data sets, place them in a collection class and perform some operation.  There is also a few data files to accompany this program.  Complete the methods specified by their documentation.  Run the program and record the timings for the different data types and data sets. AP1G, AP1B  
Grocery List Using the List collection (not ArrayList) create a program that will store a grocery list.  You should be able to add to the list, remove from the list, view the list, and find the total grocery bill for the list AP1G, AP1B, This will involve a helper object, grocery item that records the name and price of an object

Unit AP 2:Recursion

Concentric Circles Create an objectdraw application that creates concentric circles using a recursive function.  The user should click twice to provide starting values for the circles (first click = center of circles, second click = radius when compared to first)  AP2A, AP2B  
Concentric Squares Modify the concentric circles application so that it draws concentric squares instead of circles.  AP2A, AP2B  
Fibonacci Series Write a program that uses a JOptionPane to input the number of iterations for Fibonacci and write the resulting series to the screen.  AP2A, AP2B  
War Work with your partner to design objects for the game of war.  Use recursion in your playing algorithm.  The game should play a user against the computer.  AP2A, AP2B Group project.
Blog You are writing a program that will be used to store posts in a blog.  Write a recursive algorithm that will display the blog entries in reverse order, most recent first (even though they are stored sorted by date…)  AP2A, AP2B Students will need to recurse a linked list and print as the recursion unwinds. The linked list structure will be provided in a .class file and api documentation

 

Unit AP 3: Built in Arrays/2D Arrays

Create/Print Checkers Write a program that creates a board class (class board) that has a private member variable to store the position of a checker board.  Each square on the board should hold a charachter ('R' for red, 'B' for black, '-' for no piece).  Write a constructor for the board that assigns starting positions for each peice, as well as a print board function that shows the current state of the board. (Download the display class which will use your board) AP3G, AP3F Students will be given a display class that will draw a board into a window reading the R or B and drawing the square that color
Checkers Move v.1 Add to your checkers program so that it will inputbox a single move (use row and column numbers).  The play method of your program should do the input and output and call a move function in the board class. AP3G, AP3F Use JOptionPane. showInputDialog() to input values
Checkers Move v.2 Add two valid move functions to the checkers class that returns a boolean value based on whether the move is valid or not.  One of the functions should check a move without a jump, and one function should check for a single jump (Bonus: Check for multiple jumps – no backwards…) AP3G, AP3F  
Boggle v.1 Download the boggle class from the share folder that reads in a boggle matrix and a word list from files.  Implement the methods that search horizontally and vertically in the boggle matrix for words read in from a wordlist file. AP3C, AP3D  
Seating Chart Read a list of student names from a file and use a random number generator to randomly assign the students to a square matrix representing a seating chart.  Download the program from the share folder and implement the seat() method. AP3C, AP3D The program will already have a constructor that reads in the names from the chart, and a display method that writes them to the screen.
Boggle v.3 Implement a diagonal search inside the boggle program (words can be on the diagonal). AP3C, AP3D, AP3G  
Boggle v.4 Write a main that will randomly generate a boggle board and allow a user to find words within the board (use your boggle class for the functions already implemented) AP3G Use JOptionPane to input word found and game tells user whether it is in board or not

 

Unit AP 4: Stacks and Queues

Homework List Download the Homework List program from the share folder.  Implement a data structure that stores the homework in a priority queue based upon due date.  Include options for entering new assignments, completing next assignment, viewing next assignment, and clearing the list. AP4B, AP4C Students will need to implement an object for individual assignments as well as the object that ties it together into the list.  JOptionPane will be used to enter new assignments.
Grading Quizzes Download the QuizStack program from the share folder.  Implement a stack and the grade method so that you will check the answers in each quiz, and set the grade in the order that they appear in the stack. AP4B, AP4C Students must traverse a built in array of ints that correspond to an answer array to accumulate correct answers, as well as average/high/low scores for the whole class.

 

 

 

 

 

 

 

 

Unit AP 5: List and Tree Implementations

Class Schedule 2 We have previously created a program using the built in list collection that stored a student’s class schedule.  Download the APList class and fill in the appropriate methods to complete the implementation of the List interface AP5B, AP5C Methods to implement include: add, clear, contains, containsAll, get, indexof, lastindexof, remove, set, sublist, toArray
Library Download the library program from the share folder.  Implement the specified methods to complete a data structure to store books being checked out. AP5B, AP5C  
Question Tree Create a question tree (discussion in class) that will enable a computer to play a guessing game.  The topic for the game will be up to you. AP5D, AP5E, AP5F  

 

 

 

 

 

 

 

 

Unit AP 6: Object Oriented Design/Large Systems

Case Study

Part V

Complete Case Study Assignments for Part V   Involves reimplementing the environment with a variety of data structures.
Large System Design Project Design a computer program based on the specifications given in class.  You may design a game, or data storage structure with your group.  I have final approval of all topics. AP6A, AP6B, AP6C, AP6D Students will use CRC cards to create a complex, OO system.  They will work in teams for this project.

 

 

 

 

 

 

Unit AP 7: AP Review/Focused Problems

...Program assignments will reflect individual needs of each student