day 3 - COP 3330 Object-Oriented Programming Summer 2007...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
COP 3330: Introduction Page 1 © Mark Llewellyn COP 3330: Object-Oriented Programming Summer 2007 Introduction to Object-Oriented Programming Part 2 School of Electrical Engineering and Computer Science University of Central Florida Instructor : Mark Llewellyn [email protected] HEC 236, 823-2790 http://www.cs.ucf.edu/courses/cop3330/sum2007
Background image of page 1

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

View Full DocumentRight Arrow Icon
COP 3330: Introduction Page 2 © Mark Llewellyn Another Applet Program -- StickFigureApplet.java // A Java applet program which draws a stick figure body import java.awt.*; import java.applet.Applet; public class StickFigureApplet extends Applet { public void paint (Graphics page) { page.drawString("A Stick Figure", 100,30); // Head page.drawOval(100,50,50,50); page.drawOval(115,65,5,5); // eyes page.drawOval(130,65,5,5); page.drawLine(125,70,125,80); // nose page.drawLine(120,85,130,85); // mouth // Body page.drawLine(125,100,125,150); // Legs page.drawLine(125,150,100,200); page.drawLine(125,150,150,200); // Hands page.drawLine(125,125, 75,100); page.drawLine(125,125,175,125); } // end of paint method } // end of class
Background image of page 2
COP 3330: Introduction Page 3 © Mark Llewellyn Another Applet Program (cont.) StickFigureApplet.html <html> <applet code=“StickFigureApplet.class" width=300 height=300> </applet> </html> drawString(astring,x,y) writes the given string starting from the <x,y> coordinate.
Background image of page 3

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

View Full DocumentRight Arrow Icon
COP 3330: Introduction Page 4 © Mark Llewellyn Another Applet Program (cont.) drawLine(x1,y1,x2,y2) draws a line from <x1,y1> to <x2,y2> coordinate. drawOval(x,y,width,height) draws an oval with given width and height (if the oval were enclosed in a rectangle). <x,y> gives the top left corner of the rectangle.
Background image of page 4
COP 3330: Introduction Page 5 © Mark Llewellyn Output of StickFigureApplet
Background image of page 5

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

View Full DocumentRight Arrow Icon
COP 3330: Introduction Page 6 © Mark Llewellyn JAVA API (Application Programming Interface) The Java API is a set of a class libaries. The classes of the Java API are grouped into packages. Each package contains related classes. A package may contain another packages too. We can access a class explicitly: java.lang.System (the . separates packages and classes). Or, we can access all classes in a package at the same time: java.awt.*
Background image of page 6
COP 3330: Introduction Page 7 © Mark Llewellyn JAVA API (cont.) Some packages in the Java API. java.lang general support, it is automatically imported into all Java programs java.io perform a wide variety of input output functions java.awt graphics related stuff (awt-Abstract Windowing Toolkit) java.applet to create applets java.math mathematical functions. .
Background image of page 7

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

View Full DocumentRight Arrow Icon
COP 3330: Introduction Page 8 © Mark Llewellyn The import Statement We can access a class by giving its full name such as java.awt.Graphics . But we will repeat this over and over again in our programs. The import statement identifies the packages and the classes of the Java API that will be referenced in our programs.
Background image of page 8
COP 3330: Introduction Page 9 © Mark Llewellyn The import Statement (cont.) import package . class identify the particular package that will be used in our program.
Background image of page 9

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

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 94

day 3 - COP 3330 Object-Oriented Programming Summer 2007...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online