Category Archives: Homework

GUI: JFrame

Classwork:
Use a JFrame to create an application, YI_ManyShapes.java and YI_ManyShapesJFrame.java that draws rectangles, ellipses and lines. Use different colors and fill.
Here is a good source for your application:
Screen Shot 2014-10-28 at 5.47.35 AM

Here is a simple example:

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import javax.swing.JComponent;
/**
 * Write a description of class RectangleObject here.
 
 */
public class RectangleObject extends JComponent
{
    public void paintComponent(Graphics g)
    {
      Graphics2D g2 = (Graphics2D) g;

      // Construct a rectangle object
      Rectangle box = new Rectangle(5, 10, 20, 30);
      // draw the rectangle
      g2.draw(box);  
    }
   
}

The JFrame class:

import javax.swing.JFrame;
/**
 * Draw an empty frame using JFrame.
 * 
 */

public class RectangleJFrame
{
       public static void main(String[] args)
    {
        JFrame frame = new JFrame();
        frame.setSize(300,400);
        frame.setTitle("A Rectanlge Object in a JFrame");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        RectangleObject aRectangle = new RectangleObject();
        
        frame.add(aRectangle);
        frame.setVisible(true);
    }
}

Homework:
Write an application, YI_HappyFace.java using what you learned from Manyshapes to draw a happy face. Make sure to include the JFrame class also.

Pi Day Activity

March 11th, 2016

pi1

Monday is Pi Day – We will have a pi-day activity ending on Monday.
Starting today we are celebrating Pi day by preparing to write a program to do one of the following:
1. Calculate the digits of Pi to highest possible precision. DOCUMENT YOUR MATHEMATICAL EXPRESSION AND THE LINK TO THE RESOURCE.
2. Illustrate how Pi is used in a circle.
3. Illustrate how Pi can be applied.
4. Illustrate how Pi was discovered by telling an interactive story.

300px-Circle_radians

220px-2pi-unrolled

From https://en.wikipedia.org/wiki/Radian

The programs will be judge based on ingenuity and/or creativity.
NOTE: You can use online resources to help you develop your program. There are good algorithms online. You can not use already written programs.
Include any links used for your resources.

If you like to memorize some of the digits of pi, there will be a competition on Friday. The student who can write the most digits without any help, get a small trophy.

Homework: Explore and investigate the uses and history of pi.

Event: Philadelphia Classic Spring 2014

December 4th, 2014

Philadelphia Classic Spring 2014 Contest Problem Set


Screen Shot 2014-12-04 at 9.05.16 AM

Do problems 1 through 4 in class and for homework.
Work with a partner. DO NOT LOOK FOR THE SOLUTIONS

Pay special attention to the following:
1. Make sure you read the instructions in the first 2 pages.
2. Read the problem many times before you get started.
3. Draft a plan on paper or a document before you start.
4. Test parts of the code before you develop the “whole” program.
5. Do not use outside help of any sort.
6. All students have to turn in the assignments to edmodo.com