RedCross.java
1    /* 
2    write a program called RedCross within the npw package to paint a red cross (plus symbol) 
3    in a 600 by 600 canvas whose legs are 500 by 100. 
4    Featured constraint: Create and use one and only one rectangle object 
5    Other constraints: 
6     
7        Use the technique of modifying an existing program that does something similar. Do so by: 
8        (a) Creating a new Java Class file for the program, naming it RedCross and placing it in the npw package. 
9        (b) Replacing the entire contents of the RedCross file with the entire contents of the BlueDot program. 
10       (c) Changing all occurrences of BlueDot to RedCross. 
11       Place all of the code for creating and using the sole rectangle object in the paintTheImage method. 
12    */
13   package npw;
14   
15   import java.awt.Color;
16   import javax.swing.SwingUtilities;
17   
18   import painter.SPainter;
19   import shapes.SCircle;
20   import shapes.SRectangle;
21   
22   public class RedCross {
23       //The Solution to the RedCross problem
24       private void  paintTheImage() {
25           SPainter HDunant = new SPainter ("Redcross", 600,600);
26           SRectangle Cross = new SRectangle(500,100);
27           HDunant.setColor(Color.RED);
28           HDunant.tl(90);
29           HDunant.paint(Cross);
30           HDunant.faceNorth();
31           HDunant.paint(Cross);
32           //
33   
34   
35       }
36       //Required infrastructure
37       public RedCross() {
38           paintTheImage();
39       }
40       public static void main (String[] args) {
41           SwingUtilities.invokeLater(new Runnable() {
42               public void run(){
43                   new RedCross();
44               }
45           });
46       }
47   }
48