Make sure you can answer all of the questions from the first quiz we had. None of the questions below ask you to name types or classes or object methods or class methods, but you should be prepared to answer those.
Also review all of the six homeworks assigned to date.
ExamOne
that
prints Hello World
.
int count = 0; int age; Double pi = 3.14159; String myname = "Poindexter; boolean the answer = true;
image.jpg
.
image.jpg
by 25%. Your program should have a main
class that calls a method darken
. Write the darken
method as well and pretend that you put it in the file Picture.java
.
System.out.println("What do" + 1 + (2 + 3) + 4 + " I print?");
* ** *** **** *****
int x; x = 1/3; System.out.println(x);
FileChooser.pickAFile()
a class method or an object method?
Be prepared to answer this question about many of the methods we have used this semester.
public class Exam1 public static void main (String args) { int XXXX = 7; System.out.println(XXXX); World w = new World(); Turtle tommy = new Turtle(); tommy.forward(200) int sum = 0; for (int i = 0; i < 10; i++ { sum = sum + I; } System.out.println(sum); }
pic
already declared. Write a statement
that sets the redness of the pixel at coordinate (40,70) to zero.
pic
already declared. Write a Java statement
that sets the color of the pixel at coordinate (40,70) to black.
int sum = 0; for (int i = 4; i < 9; i++) { sum = sum + i; } System.out.println(sum);
Picture
method named
copyRegion
that given a picture object to modify and two sets of coordinates
copies a region of the current picture from the original picture object.
The first coordinate represents the upper left hand coordinate of the source picture and the
second coordinate represents the lower right coordinate of the source picture.
Here is how the method should be declared in the Picture
class. The
parameters ux
and uy
is the coordinate of the upper left
part of the region. The parameters lx
and ly
is the
lower right coordinate of the region to be copied.
public void copyRegion(Picture p, int ux, int uy, // upper left coordinate int lx, int ly) { // lower right coordinate // your code goes here }
Here is an example of how the method should be used. The example below
copies the just eye of the bug to the new picture dest
.
public class Exam1Hard { public static void main(String [] args) { Picture orig = new Picture("T:/Harcourt/Spring2008/cs140/gallery/bug.jpg"); Picture dest = new Picture(141,141); orig.copyRegion(dest,476,29,617,170); dest.show(); } }