1 /*Assignment 1, problem 1: A program to paint a red cross using only one rectangle object. 2 3 */ 4 5 package npw; 6 7 import java.awt.Color; 8 import javax.swing.SwingUtilities; 9 import painter.SPainter; 10 import shapes.SRectangle; 11 12 public class RedCross { 13 14 // The solution to the red cross problem 15 16 private void paintTheImage() { 17 SPainter Justin = new SPainter("Red Cross",600,600); 18 SRectangle Cross = new SRectangle(500,100); 19 Justin.setColor(Color.RED); 20 //Paints vertical rectangle 21 Justin.paint(Cross); 22 //Rotates painter 90 degrees to its left 23 Justin.tl(); 24 //Paints horizontal rectangle 25 Justin.paint(Cross); 26 //Rotates painter 90 degrees to its right back to the original position 27 Justin.tr(); 28 29 } 30 31 // Required infrastructure \ 32 33 public RedCross() { 34 paintTheImage(); 35 } 36 37 public static void main(String[] args) { 38 SwingUtilities.invokeLater(new Runnable() { 39 public void run() { 40 new RedCross(); 41 } 42 }); 43 } 44 } 45