// Draws many sized BJP textbooks using parameters. import java.awt.*; public class Book { public static void main(String[] args) { DrawingPanel panel = new DrawingPanel(520, 240); panel.setBackground(Color.WHITE); Graphics g = panel.getGraphics(); // draw three books at different locations/sizes drawBook(g, 20, 35, 100); drawBook(g, 150, 70, 60); drawBook(g, 300, 10, 200); } // Draws a book of the given size at the given position. public static void drawBook(Graphics g, int x, int y, int size) { // cyan background g.setColor(Color.CYAN); g.fillRect(x, y, size, size); // white "bjp" text g.setColor(Color.WHITE); g.drawString("BJP", x + size/2, y + size/5); // orange "bricks" g.setColor(new Color(191, 118, 73)); for (int i = 0; i < 10; i++) { g.fillRect(x, // x y + size/10 * i, // y size/10 * (i + 1), // width size/10 - 1); // height } } }