OO Java Assignments
 

  Ms Gold's

Computer Science Classes at Marshfield High School

last updated August 28, 2010 4:59 PM

Object Oriented Programming

 

Link to Lesson Plans

Resources
Java Concepts 6th Edition - Java - Cay Horstmann

Link to Power Point: Class Procedures, Schedules, and Assessments

For Students and Parents: Object Oriented, Java and Alice Programming Schedule and Assessments

Important Information:
Improper use of the Internet during class time will result in the loss of computer use for the day, the student will have to make up lost class time and work after school. Improper use is defined as visiting an internet site that has not been sanctioned by the school or teacher. This includes but is not limited to all types of games that are not related to class work.

In addition, adding unrelated files to the school's computer network will result in immediate loss of all internet privileges.

 

Homework Assignment

Read chapters 1 and 2 of your text book - Java Concepts

Section 1

Lecture

  • Name, web-site, and email address on the board
  • Objective - Start thinking how to design an Asteroid Game in an Object Oriented Way
    • On a piece of paper write down ideas for designing a Asteroid Game -
    • Brain Storm the Class structure of a basic Asteroid Game
    • Break into groups to plan out class design
    • Go over with class the design
    • Compare the class design to how it would be designed in Game Maker
  • Time Permitting - Start Class procedures
  • Class can sign on
  • Lecture - Objective-Introduce class to Web site and class procedures
    • Show Web page and links
    • Give out Textbooks - OO
    • Create an MO folder that looks like the following:
      • MO_Java
        • Java
          • Project1
        • Alice
          • Project1
        • WebSite
    • Create Shortcuts
      • Create a short-cut to Alice in C -> Documents and Settings- > your account\desktop\Alice\Alice.exe
      • Create a short-cut to Eclipse C-> Eclipse\Eclipse.exe
    • Demo how to run a program in Eclipse and how to make a workspace
    • Demo Run Hello World - Introduction to Eclipse Steps to Running Eclipse and Writing Hello World
  • Computer

Date to be Decided

Complete Chapter 3 Worksheet Link to Study Guide for Test

Lesson 5

Lesson 6

Lesson 7

Assignment -Determine that a collision has happened when the the ball collides with each boundary of the window. Use this code as your foundation

The Tutorials are now working, but through Internet Explorer Only! Eclipse and Java Tutorials

Lesson 8

Code for resizable Ellipse

import javax.swing.JComponent;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;

/**
A component containing an ellipse filled with your favorite
color that touches the component boundaries.
*/
public class EllipseComponent extends JComponent
{
public void paintComponent(Graphics g)
{
// Draw a large ellipse that touches the boundaries of this component.

Graphics2D g2 = (Graphics2D) g;

double width = getWidth();
double height = getHeight();
// it's that easy.

Ellipse2D oval = new Ellipse2D.Double(0, 0, width, height );

g2.setColor(Color.RED);
g2.fill(oval);

g2.setColor(Color.BLACK);
g2.draw(oval);
}
}

 
Lesson 9 - Three Players One Class How one Laser Class Download the following java files and Main.java Load these files into Eclipse and create 3 Players. Create Four Players from only ONE Class that does the following.
  1. Each Player will be a different Size
  2. Each Player will be a different Color
  3. Each Player will be at a different position
  4. and one Player will only move up and down to whatever keys you like
  5. This MUST be implemented with the new KeyListener Methods.

Collisions -

Link to simple Collision Code -

Ball.java and Paddle.java

Link to Test Collision Code

Better Collision Testing Code

/*
* Ms Gold - test to see if Asteroid is hit by a beam
* x is the x position of the beam
* y is the y position of the beam
* r is the radius of the beam
*/

public void testAstCollision(int x, int y, int r)
{
     /*
      * a is the bounding box for the Asteroid
      * b is the bounding box for the beam
      */
      Rectangle a = new Rectangle(x_pos, y_pos, radius*2, radius*2);
      Rectangle b = new Rectangle(x, y, r*2, r*2);

      if (a.getBounds().intersects(b)){
         x_pos = -100; // temporary solution is to move asteroid off screen
         y_pos = -100;
          System.out.println("GONE");
      }

}

 

*************************************************************************************************************

 

Before you hand in code

Code Requirements

Comments
Top of program should include
Your name -
any parameters -
the date -
A description of what the program does -
How to deploy your program outside of Eclipse. I want this tested and don't forget about images.
All instance variables are to be commented
On top of each method -
A explanation of purpose of the method
explain each of the parameters and return values
In addition, comment all important lines of code.

Conventions To Follow

Start class names with a Capital Letter
Start variable names with a lower case letter
Always camelCase - it's easy to type and easy to read
Always indent - code that is not indented I will not be debugged or grade
Always comment - non-commented code will not be graded

 

Object Oriented and Computer Programming Vocabulary List

General Java Programming Vocabulary List

General Programming Vocabulary List

Helpful Links

Java online Course eimacs.com

Contents we will cover in eIMACS

The Secret Life of Data

Java Game Tutorial - DOWNLOAD THE SOURCE CODE - The code on the Web pages are NOT always correct, but the downloaded source code will work!!

Eclipse and Java Tutorials

Link to Java Reserve Words - Warning - Do Not use these words as Variable Names

List of Open Source Projects

List OO Vocabulary List

JavaBat- Java Practice Problems

Sun Java API's 5

Java cscie160 -For Distributed Programming

Sun the Really Big Index

Sun OO Tutorials

Sun Java Package Tutorial

How to Write Doc Comments for the Javadoc Tool

Partial list of Character ASCII translations

Link to Horstmann Chapter 1 power point

Java Coding Style Guidelines

Sun Tutorials

KeyListener http://goldclasses.com/java/Lessons/KeyListener.htm

Mouse Listener. In this exercise the a box will follow your Mouse. Follow instructions on pg 422 -425 of the Big Java Book Link to Mouse Listener Code on page 422-425

Mathematical Definition of reciprocal is a number that you multiply by so that the result equals 1. The easiest way to find it is to just flip the fraction over.

Here's an example: What is the reciprocal of 3?
3 is the same as 3/1, so we flip and the reciprocal is 1/3

Reciprocal of 4/5 is 5/4
Change to a fraction --> 5/2, then flip --> 2/5