Problems


[Page 249]

7.1

What are each of the following:

  • Compression

  • A constant

  • Vector graphics

  • Bitmapped graphics

  • A package

  • Inheritance

  • An interface

7.2

Use the Java API to answer the following questions:

  • What method of the String class would help you check if a string ends with a certain sequence of characters?

  • What method of the String class would tell you the first position of a character in a String object?

  • What method of the String class would tell you the last position of a character in a String object?

  • What method of the String class removes extra spaces before and after the other characters?

7.3

Use the Java API to answer the following questions:

  • What methods of the String class are inherited?

  • What class does the String class inherit from?

  • What class does the Math class inherit from?

  • What class does the Integer class inherit from?

  • What interfaces are in the package java.lang?

  • Which classes implement the Comparable interface?

  • What interfaces does the String class implement?

7.4

Which of the following use bitmapped graphics:

  • JPEG

  • Flash

  • BMP

  • GIFF

  • Postscript

  • AutoCAD

7.5

Using the drawing tools presented here, draw a housejust go for the simple child's house with one door, two windows, walls, and a roof.

7.6

Create a method that will add a cartoon type word balloon to your picture.


[Page 250]
7.7

Put a cabana on the beach. Draw the house from the previous exercise on the beach where we put the mysterious box previously.

7.8

Now use your house to draw a town with dozens of houses at different sizes. You'll probably want to modify your house method to draw at an input coordinate, then change the coordinate where each house is drawn.

7.9

Draw a rainbowuse what you know about colors, pixels, and drawing operations to draw a rainbow. Is this easier to do with our drawing methods or by manipulating individual pixels? Why?

7.10

Modify the method drawFace to take the width and height of the desired face and calculate the positions based on the desired width and height.

7.11

Draw glasses on a picture of a person who doesn't normally wear glasses.

7.12

Draw a hat on someone in a picture.

7.13

Draw a weight over someone in a picture.

7.14

Draw a string on a picture at the top of the picture and centered horizontally. You will need to use the FontMetrics class to get the height of the string in pixels in order to determine where the baseline should be so that the string is visible. You should also subtract the descent from the height.

7.15

Create another method that takes the text, x, y, font and color to use when you draw a string. Rewrite the old drawString() method to call this new method.

7.16

Create a method that draws an X across the current picture using dashed lines.

7.17

Create a method that draws bars across the current picture using thick lines.

7.18

Write a general rotate method that takes the degrees to rotate the current Picture object and returns a new Picture object. Use the AffineTransform.rotate(double radians) method to do this. You will need to use the general Math.toRadians(int degrees) method to translate the degrees to radians.

7.19

Write a method to draw a text string rotated 90 degrees to the right down the right side of the picture.

7.20

Write a method to overlap two pictures vertically using an AlphaComposite object.

7.21

Write a method to clip an image to a triangle or star shape.



Introduction to Computing & Programming Algebra in Java(c) A Multimedia Approach
Introduction to Computing & Programming Algebra in Java(c) A Multimedia Approach
ISBN: N/A
EAN: N/A
Year: 2007
Pages: 191

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net