Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Final Exam Cheat Sheet on Data Structures and Algorithms, Cheat Sheet of Data Structures and Algorithms

CSC1051 Data Structures and Algorithms at Villanova University

Typology: Cheat Sheet

2020/2021
On special offer
30 Points
Discount

Limited-time offer


Uploaded on 04/23/2021

alpa
alpa 🇺🇸

4.4

(19)

8 documents

Partial preview of the text

Download Final Exam Cheat Sheet on Data Structures and Algorithms and more Cheat Sheet Data Structures and Algorithms in PDF only on Docsity! 2/26/13 1 CSC 1051 M.A. Papalaskari, Villanova University //******************************************************************** // Einstein.java Author: Lewis/Loftus // // Demonstrates a basic applet. //******************************************************************** import javax.swing.JApplet; import 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 (60, 80, 225, 30); // rectangle page.drawOval (75, 65, 20, 20); // circle page.drawLine (35, 60, 100, 120); // line page.drawString ("Out of clutter, find simplicity.", 110, 70); page.drawString ("-- Albert Einstein", 130, 100); } } Drawing a Line 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 Drawing a Rectangle X Y page.drawRect (50, 20, 100, 40); 50 20 100 40 CSC 1051 M.A. Papalaskari, Villanova University Start x y Width Height Drawing an Oval X Y page.drawOval (175, 20, 50, 80); 175 20 50 80 bounding rectangle CSC 1051 M.A. Papalaskari, Villanova University Drawing an Arc •  An arc is defined by an oval, a start angle, and an arc angle: CSC 1051 M.A. Papalaskari, Villanova University Filled vs unfilled shapes •  Instead of using drawRect(), drawOval() etc, we can use fillRect(), fillOval() etc •  We can set the color using setColor() •  See Snowman.java •  See also Snowman applet on a webpage 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.       Some  methods  of  the  Random  class   double nextDouble() Returns the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 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.     Some  methods  of  the  Math  class   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.   Some Java Escape Sequences and their meaning: \t tab \n newline \" double quote \' single quote \\ backslash
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved