OO Java Assignments
 

  Ms Gold's

Computer Science Classes at Marshfield High School

last updated 3/8/10

Object Oriented Programming

3/9/2010 Three Players One Class

Link to Progress Report's Assessments

Link to Lesson Plans

Resources
Text Big Java - Cay Horstmann
AP Java - Maria Litvin
www.eimacs.com

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

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

Section 1

Lesson 1 9/4

  • Name, web-site, and email address on the board)
  • Objective-Introduce class to Web site and class procedures
  • Objective - Start to think about the intricacies of designing a computer game using a simplified version of MineSweep
    • On a piece of paper write down ideas for designing a simple mine sweep game - anything goes
    • Lets brain storm in a group
    • Break into groups for 5 minutes to plan out the design of the game and answer the following questions
      • What will the game do?
      • How to represent it internally?
      • How would you populate the bombs differently for each game
      • Draw your internal representation of the game board
    • Use case scenarios are widely used in the industry. It is where you walk through what a user would do and then you the designer/programmer will calculate how your program will react.
      • Use Case 1: User clicks left clicks on 2,2
      • Use Case 2 - Draw out what the user will see if they Left clicked 0, 3-
        Right click you will see a Flag
      • Use Case - What will the user see if she left clicks in 1,1
      • How to check for bombs
        original
    • What methods do we need
      • what are the methods we need / think of tic tac toe
      • isBomb() -
      • isValidFlag - count
      • getAdjacentLocation()
      • isWinner() -
        • Right or left Click
        • Left click -Is cell a bomb if is exit
        • Left Click and the cell is empty
          • Go through all 8 possible touching cells
          • Display to the user a number or a blank cell
        • Keep doing this till winner- need to keep track of flags and bombs
  • Time Permitting open up Alice
  • Summation - progress report on line
  • Lecture
    • Since the internal representation of mine sweeper records the number of mines around a cell; Write an algorithm that counts the number of randomly placed cells with bombs around and 8 cell area in which a user has picked.
    • What methods do we need
      • what are the methods we need / think of tic tac toe
      • isBomb() -
      • isValidFlag - count
      • getAdjacentLocation()
      • isWinner() -
        • Right or left Click
        • Left click -Is cell a bomb if is exit
        • Left Click and the cell is empty
          • Go through all 8 possible touching cells
          • Display to the user a number or a blank cell
        • Keep doing this till winner- need to keep track of flags and bombs
    • Demo how to run a program in Eclipse and how to make a workspace
    • Assignment 1
    • Assignment 2
      • 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
      • H:/00/Journal/yourFirstInitialLastNameJournal.doc, H:/OO/Alice , H:/OO/workspace (can do this from within Eclipse), H:/OO/MO/Website
    9/29 (still out, email me through eimacs)I've added a Power Point on Chapter 3 of Big Java- Check it out!

Lesson 4 Week starting 10/25

Test November 3rd

Complete Chapter 3 Worksheet Link to Study Guide for Test

Lesson 4 10/25

Lesson 5 11/08

Assignments Due 12/8 for Progress Reports

Lesson 6 11/30

Lesson 7 - 1/19/2010

Assignment 1/19/2010 - 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

Due By Friday 3/5 For Progress Reports
  • A Game Document describing your game and the additions that you have made to the game. This document will be place in a Directory called H:/OO/Game/paFirstGame.doc (Where the first letter is your first initial and the second letter is your second initial) followed by the words FirstGame.
  • Your games should implement the 1.5 java Mouse and Key Listener Interfaces. Refer to the links above and the 1.5 java api.
  • Your game should have a separate classes for each of its' objects for example, a Ball class, a Player class, an Opponent class, etc...
  • All code MUST be aligned correctly
  • All coded MUST be reasonably commented -
    • the top of each class
      • should have your name
      • the class name
      • the purpose of the class
    • each method
      • inputs and outputs
      • description of what it does
  • Your code should run. If it does not run or does not run properly leave me a separate note called MsGold.doc explaining the problems that you have had.

Lesson 9 - 3/9/10

Three Players One Class

How one Lazer 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 do the following.

  1. Each Player will be a different Size
  2. Each Player will be a diferent 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.

 

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

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);
}
}

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

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

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

The Secret Life of Data

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

AP Java online Course eimacs.com

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