

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


CSC 1051 M.A. Papalaskari, Villanova University //******************************************************************** // Einstein.java Author: Lewis/Loftus // // Demonstrates a basic applet. //******************************************************************** import import javax.swing.JApplet;java.awt.*; public { class Einstein extends JApplet //----------------------------------------------------------------- // Draws a quotation by Albert Einstein among some shapes. //----------------------------------------------------------------- public void paint (Graphics page) { page.drawRect (50, 50, 40, 40); // square page.drawRect page.drawOval (60,(75, 80,65, 225,20, 20);30); //// rectanglecircle page.drawLine (35, 60, 100, 120); // line page.drawString page.drawString ("Out("-- Albertof clutter, Einstein", find simplicity.",130, 100); 110, 70); }^ }
X Y 10 20 150 45 page.drawLine (10, 20, 150, 45); page.drawLine (150, 45, 10, 20); or CSC 1051 M.A. Papalaskari, Villanova University Start x y End x y
X Y page.drawRect (50, 20, 100, 40); 50 20 100 40 CSC 1051 M.A. Papalaskari, Villanova University Start x y Width^ Height
X Y page.drawOval (175, 20, 50, 80); 175 20 50 80 bounding rectangle CSC 1051 M.A. Papalaskari, Villanova University
CSC1051 Data Structures and Algorithms I Dr. Papalaskari Some methods of the String class boolean (^) isEmpty () Returns true if, and only if, length() is 0. char (^) charAt (int index) Returns the char value at the specified index. int (^) length () Returns the length of this string. String toUpperCase () Converts all of the characters in this String to lower case using the rules of the default locale.
double (^) nextDouble () Returns the next pseudorandom, uniformly distributed double value between 0.0 and 1. int (^) nextInt () Returns the next pseudorandom, uniformly distributed int value from this random number generator's sequence. int (^) nextInt (int n) Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.
static double (^) abs (double a) Returns the absolute value of a double value. static double (^) cos (double a) Returns the trigonometric cosine of an angle. static double (^) pow (double a, double b) Returns the value of the first argument raised to the power of the second argument. static double (^) random () Returns a double value greater than or equal to 0.0 and less than 1.0. static long (^) round (double a) Returns the closest long to the argument. static double (^) sin (double a) Returns the trigonometric sine of an angle. static double (^) sqrt (double a) Returns the correctly rounded positive square root of a double value. So me Ja va Es ca pe Se qu e nc es a nd th eir mea n in g: \t tab \n newline " double quote ' single quote \ backslash