Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: simyseng/CS106A
base: f2666c34c7
...
head fork: simyseng/CS106A
compare: 7b8d709e8c
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 11 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jul 21, 2013
@simyseng Problem Set 3
Added
efe3691
@simyseng subproject removed
subproject removed
7b8d709
View
BIN  Problem Set 3/.DS_Store
Binary file not shown
View
7 Problem Set 3/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path=""/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="acm.jar"/>
+ <classpathentry kind="output" path=""/>
+</classpath>
View
17 Problem Set 3/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>Empty Project</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
View
12 Problem Set 3/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+#Fri Jul 12 14:38:05 SGT 2013
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
View
BIN  Problem Set 3/MouseTracker.class
Binary file not shown
View
19 Problem Set 3/MouseTracker.java
@@ -0,0 +1,19 @@
+import acm.program.*;
+import acm.graphics.*;
+import java.awt.event.*;
+
+public class MouseTracker extends GraphicsProgram {
+ public void run() {
+ label = new GLabel("");
+ label.setFont("Times New Roman-36");
+ add(label, 50, 50);
+
+ addMouseListeners();
+ }
+
+ public void mouseClicked(MouseEvent e) {
+ label.setLabel("Mouse: (" + e.getX() + ", " + e.getY() + ")");
+ }
+
+ private GLabel label;
+}
View
BIN  Problem Set 3/RandomCircles.class
Binary file not shown
View
44 Problem Set 3/RandomCircles.java
@@ -0,0 +1,44 @@
+import java.awt.Color;
+import acm.program.*;
+import acm.util.RandomGenerator;
+import acm.graphics.*;
+
+public class RandomCircles extends GraphicsProgram{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ public void run() {
+ /* Creates 10 random circles */
+ for(int i = 0 ; i < 10 ; i++) {
+ createRandomCircle();
+ }
+ }
+ /**
+ * Creates a random circle of size between 50 and 300 px
+ * @Creates a random circle of size between 50 and 300 px
+ */
+ private void createRandomCircle() {
+ /* Creates a random circle */
+ double diameter = rgen.nextDouble(SMALLEST_DIAMETER, LARGEST_DIAMETER);
+ GOval circle = new GOval(diameter, diameter);
+ Color color = rgen.nextColor();
+ /* Get another random color if white was returned */
+ while(true) {
+ if(color != Color.WHITE) break;
+ color = rgen.nextColor();
+ }
+ circle.setColor(color);
+ circle.setFilled(true);
+
+ /* Create a random coordinates set */
+ double x = rgen.nextDouble(0, getWidth() - diameter);
+ double y = rgen.nextDouble(0, getHeight() - diameter);
+
+ add(circle, x, y);
+ }
+
+ private static final RandomGenerator rgen = new RandomGenerator();
+ private static final double SMALLEST_DIAMETER = 10;
+ private static final double LARGEST_DIAMETER = 250;
+}
View
BIN  Problem Set 3/RubberBanding.class
Binary file not shown
View
20 Problem Set 3/RubberBanding.java
@@ -0,0 +1,20 @@
+import acm.program.*;
+import acm.graphics.*;
+import java.awt.event.*;
+
+public class RubberBanding extends GraphicsProgram {
+ public void init() {
+ addMouseListeners();
+ }
+
+ public void mousePressed(MouseEvent e) {
+ line = new GLine(e.getX(), e.getY(), e.getX(), e.getY());
+ add(line);
+ }
+
+ public void mouseDragged(MouseEvent e) {
+ line.setEndPoint(e.getX(), e.getY());
+ }
+
+ private GLine line;
+}
View
BIN  Problem Set 3/acm.jar
Binary file not shown

No commit comments for this range

Something went wrong with that request. Please try again.