BPIIW1 - COMPUTER PROGRAMMING II 2012 WEEK 1 WEEK1 CLASS...

Info icon This preview shows pages 1–3. Sign up to view the full content.

COMPUTER PROGRAMMING II 2012 WEEK 1 WEEK1 CLASS EXERSIZES (Wil be shown at the and of Lab class) EX1 ) study class starP and draw a triangle by using a similar program triangleP . You give the traingle coordinates. class H1Ex7 { public static void main(String args[]) { starP pp=new starP(); FrameGraphic.plot("Plot window",pp); }} import javax.swing.*; import java.awt.Graphics; import java.awt.*; import java.awt.event.*; import java.awt.geom.*; public class starP extends JPanel { public void paint(Graphics g) { int x[]={55,67,109,73,83,55,27,37,1,43}; int y[]={0,36,36,54,96,72,96,54,36,36}; Graphics2D g2=(Graphics2D)g; GeneralPath star=new GeneralPath(); star.moveTo(x[0],y[0]); for(int i=1;i<x.length;i++) {star.lineTo(x[i],y[i]);} star.closePath(); g2.setColor(Color.blue); g2.draw(star); } }
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

The shape you should draw: EX2 ) study class plot2P. Plot fonction y=x*x-2/x by using class plot2P between x=1 and x=5 . Use FrameGraphic. import javax.swing.*; import java.awt.Graphics; import java.awt.*; import java.awt.event.*; import java.awt.geom.*; abstract class f_x { abstract double func(double x);} public class plot2P extends JPanel { int x[]; int y[];
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.
  • Fall '13
  • lab class, class plot2P

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern