OO Java Assignments
![]()
Ms Gold's
Computer Science Classes at Marshfield High School
last updated 4/28/10
Object Oriented Programming
Assessment for Game
A
-Game Ready for Monday, May 3th at 2:00
-game is in .jar file format
-and link works in html file OO.htm
B
-Game Ready for Tuesday May 4th at 2:00 (I we will be installing the games between 2 and 3)
-game is in .jar file format
-and link works in html file OO.htm
Anything less than C or less
To achieve this you can work in teams.
Test on Collisions - Monday 5/10
Better Collision Code and Pick up Your Code Here 4/26
Link to Collisions (4/9)
Today - Due 3/29 Print out your Updated Game Document which will include the Name and Full Pathname of your Game and Game Document. If this information is not delivered to me by Thursday (the end of the Term), or is incorrect you will receive an F for the project.TERM 3 Assessments
3/9/2010 Three Players One ClassLink to Progress Report's Assessments
- 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. Game documents should now be fully completed and ready for posting.
- 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.
- Don't forget a separate note explaining special circumstances. For example, code you tried and didn't work, or problems you had that were particularly frustrating.
ResourcesText Big Java - Cay HorstmannAP 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
This year spend 1/2 year learning java and then we make games. The more you understand in the beginning the better the games.- Power Point Link to Power Point: Class Procedures, Schedules, and Assessments
Show Web page and links Give out Textbooks - OO and hopefully emac's accounts Read Chapter 1 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
- Lesson 2a - Sept 9/9 and Lesson 2b - 9/11 Continue to complete the assignments- If you have difficulty with one assignment, stop what you are doing, and go on to another one.
- 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.
9/29 (still out, email me through eimacs)I've added a Power Point on Chapter 3 of Big Java- Check it out!
- 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
- Run Hello World - Introduction to Eclipse Steps to Running Eclipse and Writing Hello World
- Compile and run our first Hello World program
- 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
- Lesson 3 - 9/15 (Tues), 9/ 17, 9/21, 9/23, 9/25, 9/29, and 10/1
Check Your EMAC EMAIL - I am Answering Them
- Lecture
- If you have difficulty with one assignment, stop what you are doing, and go on to another one.
- MUST DO! Each student must send an email via EMACs on the your progress. The email can be sent either at the beginning or end of class, but it must be sent.
- Computer
- Journal - (The Journal is being replaced with email via EMAC)
- Assignment 1
- Link to Horstmann Chapter 1 power point
- Chapter 1 of Cay Horstmann (either Big Java book or Java Concepts Books ) Programming Exercises P1.1 through p1.8 (since there are not enough book you will need to share.)
- Chapter 2 Link to Review of Chapter 2 - Using Objects - It's All Here Folks!
- Assignment 2
- Java Phenomenon Trail http://java.sun.com/docs/books/tutorial/getStarted/intro/index.html - Do the whole trail on Lesson: The Java Technology Phenomenon
- A closer look at Hello World Trail http://java.sun.com/docs/books/tutorial/getStarted/application/index.html
- What is a Class http://java.sun.com/docs/books/tutorial/java/concepts/class.html - try Lesson: A Closer Look at the "Hello World!" Application - through to the end of the trail
- Assignment 3
- All exercises and tests through and including Test 2 in eimacs http://eimacs.com/
- Chapter 2 - of the Cay Horstmann ( Big Java Book) Study Power Point. Programming Exercise p2.14 to p2.19 - They all start with G
- Assignment 4
- Do 4 Alice tutorials
- Create an Alice Project
- Assignment 5
Chapter 3 Horstmann -Implementing Classes- Summation-
- Write EMAIL through EMAC
- Lesson 3b
- Types of Variables in Java - link to java.sun.com tutorials
- Instance Variables (Non-Static Fields)
- Class Variables (Static Fields)
- Local Variables
- Parameters
- A type's fields, methods, and nested types are collectively called its members.
- After reading Chapter 2 copy and run the Graphical Applications on page 58 in Big Java (Horstmann) that displays two Rectangle in a Frame Viewer.
- Next add a color to the rectangle and add a string containing your initials. Use the following commands to add the functionality:
- g2d.setColor(Color.BLUE);
- g2d.drawString("VG", 10, 25);
- Next add an Ellipse and its Bounding Box. Follow instructions on pg 66 of the Big Java Book
- In class assignments - Review Exercises R2.1 through 2.19 - This can be done in groups of 2 or 3, but must be handed in for a grade.
- Complete Programming Exercises 2.11 through 2.15
- Culminating Chapter 2 Assignment (Will be graded as a project) P2.8 - (Your grade will be based on how well you explain your code to me not necessarily on how well your code works
- Finish up eimacs labs and tests through test 5
Lesson 4 Week starting 10/25
Test November 3rd
Complete Chapter 3 Worksheet Link to Study Guide for Test
Lesson 4 10/25
- Go over test for Monday 11/3 Link to Practice Test's Study Guide
- Chapter 3 Horstmann -Implementing Classes
- Link to Review/power point of Chapter 3 - Implementing Classes
- Complete all programming exercises at the end of the chapter that start with a G
- Chapter 4 Horstmann- Fundamental Data Types
- Link to Chapter 4 Power Point
- Complete the following assignments P 4.1, P4.2, P4.4, and 4.6
Lesson 5 11/08
- Students are to continue to do problems from Horstmann Java Book - Chapter 3 and 4 -
- The Secret Life of Data
- link to video on Variables and Objects
Assignments Due 12/8 for Progress ReportsLesson 6 11/30
- Finish problem sets 3 and 4 from Horstmann Java Book - Chapter 3 and 4 -
- Link to problem set 3 and 4
- Code must be have your name and dated and commented
- Refer to Code Requirements before you finalize your code
- link to video on Variables and Objects
- Key and Mouse Listeners (if time continue with)
- Learn how to add a Mouse Listener. In this exercise the a box will follow your Mouse. Follow instructions on pg 426 of the Big Java Book
Lesson 7 - 1/19/2010Assignment 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
Complete ALL programming problems through to problem 4.6 in Problem set 3 and 4- Key and Mouse Listeners
- Learn how to add a 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
- Continue onto to Game tutorial Java Game Tutorial
- Read and implement page one on the basic structure of an applet
- Implement the Moving the ball example- DOWNLOAD THE SOURCE CODE - The code on the Web pages are NOT always correct, but the downloaded source code will work!!
- Move onto double buffering.
- On your own implement a second ball that moves up and down. The new ball will start at mid-screen and move to the bottom of the screen and will bounce back and forth. This second vertically moving ball will start in mid-screen so as not to collide with the horizontally moving ball.
- If you get stuck keep moving on with the tutorial.
- Continue with tutorial - adding Sound, and Pictures.
- Test your program thoroughly.
1/25
Eclipse and Java Tutorials (Only with Internet Explorer)- Key Listeners - 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!!
Lesson 8 - 1/27/2010
- Review how to fill out your daily accomplishment sheets.
- Review the move the Ball code
- Game Ideas
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);
}
}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/10Three Players One ClassHow one Lazer ClassDownload 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.
- Each Player will be a different Size
- Each Player will be a different Color
- Each Player will be at a different position
- and one Player will only move up and down to whatever keys you like
- This MUST be implemented with the new KeyListener Methods.
Link to simple Collision Code -
Ball.java and Paddle.java
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");
}}
Examples of changed code
- General Cleanup
- added getters and setters
- Collision Code
- Removed extraneous code
- KeyListener
- Dominic - example Pacman code to follow
Code I did not update
- Andrew and Paul(I did not know what you need help with)
- Joe ( Not sure what to help you with)
- PJ - Looks like your game is finished . Any finishing touches?
*************************************************************************************************************
Before you hand in code
Code Requirements
CommentsTop of program should includeYour 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 commentedOn top of each method -A explanation of purpose of the methodexplain each of the parameters and return valuesIn addition, comment all important lines of code.
Conventions To Follow
Start class names with a Capital LetterStart variable names with a lower case letterAlways camelCase - it's easy to type and easy to readAlways indent - code that is not indented I will not be debugged or gradeAlways comment - non-commented code will not be graded
Object Oriented and Computer Programming Vocabulary List
- Encapsulation
- Polymorphism
- API Documentation
- accessor and mutator
- class
- constructor
- implicit parameter
- parameter
- methods - accessors and mutators
- new - instantiation
- object and object reference
- overloading
- primitive type
General Java Programming Vocabulary List
- Applets vs. Java Applications - Applet runs from a Browser and a Java Application runs as a standalone application
- JVM - Java Virtual Machine
- JRE - Java Runtime Environment
General Programming Vocabulary List
- Browser (Internet Explorer, firefox/Mozilla, Safari)
- Web Servers (IIS, Apache, Mongrel)
- HTML, XML
- PHP, CGI, Perl, Python, JavaScript
- ASP, .Net
- Ruby-on-the-Rails
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!!
Link to Java Reserve Words - Warning - Do Not use these words as Variable Names
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