Java Reference
In-Depth Information
΢΢G Exercise R2.17. What is the purpose of a graphics context?
΢΢G Exercise R2.18. Why are separate viewer and component classes used for
graphical programs?
΢G Exercise R2.19. How do you specify a text color?
Additional review exercises are available in WileyPLUS.
PROGRAMMING EXERCISES
΢T Exercise P2.1. Write an AreaTester program that constructs a
Rectangle object and then computes and prints its area. Use the
getWidth and getHeight methods. Also print the expected answer.
΢T Exercise P2.2. Write a PerimeterTester program that constructs a
Rectangle object and then computes and prints its perimeter. Use the
getWidth and getHeight methods. Also print the expected answer.
΢΢ Exercise P2.3. Write a program called FourRectanglePrinter that
constructs a Rectangle object, prints its location by calling
System.out.println(box) , and then translates and prints it three
more times, so that, if the rectangles were drawn, they would form one large
rectangle:
75
76
΢΢΢ Exercise P2.4.The intersection method computes the intersection
of two rectanglesȌthat is, the rectangle that is formed by two overlapping
rectangles:
Search WWH ::




Custom Search