Z:\Faculty\cindricbb\000work\CSC120\Java\lec18_s23\src\MUFrame.java
  1 /* CSC 120 Lecture # 18
  2  *
  3  * Decision-making with nested if statements
  4  *
  5  */
  6 
  7 import java.awt.*;
  8 import javax.swing.*;
  9 
 10 public class MUFrame extends javax.swing.JFrame {
 11 
 12     private MUPanel muPanel;
 13     
 14     // declare private data here
 15     
 16     private String school, conference;
 17     private Integer place;
 18     
 19     
 20     
 21     // constructor method
 22     public MUFrame() {
 23         initComponents();
 24         muPanel = new MUPanel();
 25         drawingPanel.add(muPanel);
 26         
 27         
 28         getValuesFromInput();
 29         
 30 //        school = "Kent State";
 31 //        conference = "MAC";
 32 //        place = 2;
 33         
 34 
 35         System.out.print(school + " finished in " + place);
 36         
 37         if ( (place%100)/10 == 1 ) {  // teens!!
 38             System.out.print("th");
 39         }
 40         else if (place%10 == 1) {
 41             System.out.print("st");
 42         }
 43         else if (place%10 == 2) {
 44             System.out.print("nd");
 45         }
 46         else if (place%10 == 3) {
 47             System.out.print("rd");
 48         }
 49         else {
 50             System.out.print("th");
 51         }
 52         
 53         System.out.println(" place in the " + conference + " conference");
 54 
 55         
 56         if (conference.equals("Big 10")) {
 57             if (place <= 8) {
 58                 System.out.println(school + " is going to the big dance!!");
 59             }
 60             else {
 61                 System.out.println(school + " does not qualify for the NCAA Tournament");
 62             }
 63         } // end if for Big 10
 64         else if (conference.equals("MAC")) {
 65             if (place == 1) {
 66                 System.out.println(school + " is going to the big dance!!");
 67             }
 68             else {
 69                 System.out.println(school + " does not qualify for the NCAA Tournament");
 70             }
 71         } // end if for MAC
 72         else if (conference.equals("ACC")) {
 73             if (place <= 4) {
 74                 System.out.println(school + " is going to the big dance!!");
 75             }
 76             else {
 77                 System.out.println(school + " does not qualify for the NCAA Tournament");
 78             }
 79         } // end if for ACC
 80         else {
 81             System.out.println("Wow, I never heard of the " + conference + " conference!");
 82         }
 83         
 84 
 85         
 86     } // end of constructor
 87     
 88     // declare other methods here
 89     
 90     public void getValuesFromInput() {
 91 
 92         school = JOptionPane.showInputDialog("Enter name of school:");
 93         
 94 
 95         Object[] listOfConfs = {"Big 10", "MAC", "ACC"};
 96         conference = (String) JOptionPane.showInputDialog(
 97                     this,
 98                     "Enter the Conference in which " + school + " plays:",
 99                     "Input the Conference",
100                     JOptionPane.PLAIN_MESSAGE,
101                     null,
102                     listOfConfs,
103                     null);
104 
105         String temp = JOptionPane.showInputDialog("In what place did " + school + " finish in the " 
106                                                 + conference + "?");
107         place = Integer.parseInt(temp);
108     } // end of getValuesFromInput();
109     
110     
111 
112     /** This method is called from within the constructor to
113      * initialize the form.
114      * WARNING: Do NOT modify this code. The content of this method is
115      * always regenerated by the Form Editor.
116      */
117     @SuppressWarnings("unchecked")
118     // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
119     private void initComponents() {
120 
121         drawingPanel = new javax.swing.JPanel();
122 
123         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
124 
125         javax.swing.GroupLayout drawingPanelLayout = new javax.swing.GroupLayout(drawingPanel);
126         drawingPanel.setLayout(drawingPanelLayout);
127         drawingPanelLayout.setHorizontalGroup(
128             drawingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
129             .addGap(0, 639, Short.MAX_VALUE)
130         );
131         drawingPanelLayout.setVerticalGroup(
132             drawingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
133             .addGap(0, 299, Short.MAX_VALUE)
134         );
135 
136         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
137         getContentPane().setLayout(layout);
138         layout.setHorizontalGroup(
139             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
140             .addComponent(drawingPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
141         );
142         layout.setVerticalGroup(
143             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
144             .addGroup(layout.createSequentialGroup()
145                 .addContainerGap()
146                 .addComponent(drawingPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
147                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
148         );
149 
150         pack();
151     }// </editor-fold>                        
152 
153     /**
154      * @param args the command line arguments
155      */
156     public static void main(String args[]) {
157         java.awt.EventQueue.invokeLater(new Runnable() {
158 
159             public void run() {
160                 new MUFrame().setVisible(true);
161             }
162         });
163     }
164     // Variables declaration - do not modify                     
165     private javax.swing.JPanel drawingPanel;
166     // End of variables declaration                   
167 }
168