Invention1.java
1    package npw;
2    
3    import painter.SPainter;
4    import shapes.SCircle;
5    import shapes.SSquare;
6    
7    import javax.swing.*;
8    import java.awt.*;
9    import java.util.Scanner;
10   
11   public class Invention1 {
12       private void interpreter() {
13           //CREATE OBJECTS TO THINK WITH
14           Color color = newColor();
15           Color color2 = newColor();
16           SPainter miro = new SPainter("Dot Thing", 400, 400);
17           miro.setScreenLocation(0, 0);
18           SCircle dot = new SCircle(90);
19           SSquare square = new SSquare(180);
20           paint(miro, dot, square, color, color2);
21           }
22   
23       private static Color newColor() {
24           String nss = JOptionPane.showInputDialog(null, "Color?");
25           Scanner scanner = new Scanner(nss);
26           // String command = JOptionPane.showInputDialog(null, "Color?");
27           int i = 0;
28           while (i <= 1) {
29               System.out.println("Color time!");
30               i = i + 1;
31           }
32           String command = scanner.nextLine();
33           if (command == null) {
34               command = "exit";
35           } //user clicked on Cancel
36           if (command.equalsIgnoreCase("blue")) {
37               return (Color.BLUE);
38           } else if (command.equalsIgnoreCase("red")) {
39               return (Color.RED);
40           } else if (command.equalsIgnoreCase("green")) {
41               return (Color.GREEN);
42           } else if (command.equalsIgnoreCase("yellow")) {
43               return (Color.YELLOW);
44           } else {
45               return(Color.BLACK);
46           }
47       }
48   
49   
50       private static void paint(SPainter miro, SCircle dot, SSquare square, Color color, Color color2) {
51           miro.setColor(color);
52           miro.paint(square);
53           miro.setColor(color2);
54           miro.paint(square.inscribingCircle());
55           miro.setColor(color);
56           dot.shrink(20);
57           miro.paint(dot);
58           miro.setColor(color2);
59           dot.shrink(40);
60           miro.paint(dot);
61   
62       }
63   
64       
65       //INFRASTRUCTURE FOR SOME SIMPLE PAINTING
66   
67       public Invention1() {
68           interpreter();
69       }
70   
71       public static void main(String[] args) {
72           SwingUtilities.invokeLater(new Runnable() {
73               ;
74               public void run () {
75                   new Invention1();
76               }
77           });
78       }
79   }
80   
81