WorkArea.java
1    package shapes;
2    
3    import npw.KanizsaSquare;
4    
5    import javax.swing.*;
6    
7    public class WorkArea {
8        private void doTheStuff() {
9            //entering the variables
10           int deskh = 26;
11           int deskw = 60;
12           int bookh = 10;
13           int bookw = 7;
14           int nobook = 2;
15           double canr = 1.25;
16           double coasts = (canr * 2);
17           int nocan = 3;
18           int nocoast = 3;
19           double plater = 5.5;
20           int noplate = 5;
21           //creating the objects
22           SRectangle desk = new SRectangle(deskh, deskw);
23           SRectangle book = new SRectangle(bookh, bookw);
24           SCircle plate = new SCircle(plater);
25           SCircle cantop = new SCircle(canr);
26           SSquare coaster = new SSquare(coasts);
27           //collective area of everything on the desk
28           double objArea = ((book.area() * nobook) + ((plate.area() * noplate) + (coaster.area() * nocoast)));
29           //the remaining area of the desk
30           double rdeskArea = (desk.area() - objArea);
31           //display the answers
32           displayAns(objArea, rdeskArea);
33       }
34   
35       private void displayAns(double objArea, double rdeskArea) {
36           System.out.println("The total area that the objects take up = " + objArea + " inches^2");
37           System.out.println("The area of the desk not obscured by the objects = " + rdeskArea + " inches^2");
38       }
39   
40       public WorkArea() {
41           doTheStuff();
42   
43       }
44   
45       public static void main(String[] args) {
46           SwingUtilities.invokeLater(new Runnable() {
47               public void run() {
48                   new WorkArea();
49   
50               }
51           });
52       }
53   }