Advertisement
Boucherwayne78

Untitled

Mar 27th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 11.82 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package oregon;
  7.  
  8. /**
  9.  *
  10.  * @author wayne
  11.  */    
  12.  
  13. import javax.swing.JOptionPane;
  14.  
  15. public class GameJFrame extends javax.swing.JFrame {
  16.  
  17.    
  18.  
  19.     /**
  20.      * Creates new form GameJFrame
  21.      */
  22.     public GameJFrame() {
  23.         initComponents();
  24.        
  25.         WagonMember member1 = new WagonMember();
  26.         member1.setName(JOptionPane.showInputDialog(this, "What is the first traveler's name?"));
  27.        
  28.         WagonMember member2 = new WagonMember();
  29.         member2.setName(JOptionPane.showInputDialog(this, "What is the second traveler's name?"));
  30.        
  31.         WagonMember member3 = new WagonMember();
  32.         member3.setName(JOptionPane.showInputDialog(this, "What is the third traveler's name?"));
  33.        
  34.         WagonMember member4 = new WagonMember();
  35.         member4.setName(JOptionPane.showInputDialog(this, "What is the fourth traveler's name?"));
  36.        
  37.         WagonMember member5 = new WagonMember();
  38.         member5.setName(JOptionPane.showInputDialog(this, "What is the fifth traveler's name?"));
  39.        
  40.        
  41.        
  42.        
  43.         City     independence      = new City("Independence", 102);
  44.         River    kansas            = new River("Kansas", 82);
  45.         River    bigBlue           = new River("Big Blue River", 118);
  46.         Fort     kearney           = new Fort("Fort Kearney", 86);
  47.         Landmark chimneyRock       = new Landmark("Chimney Rock", 86);
  48.         Fort     laramie           = new Fort("Fort Laramie", 190);
  49.         Landmark independenceRock  = new Landmark("Independence Rock", 102);
  50.         Landmark southPass         = new Landmark("South Pass", 57, 125);
  51.         River    green             = new River("Green River", 143);
  52.         Fort     bridger           = new Fort("Fort Bridger", 162);
  53.         Landmark sodaSprings       = new Landmark("Soda Springs", 57);
  54.         Fort     hall              = new Fort("Fort Hall", 182);
  55.         River    snake             = new River("Snake River", 113);
  56.         Fort     boise             = new Fort("Fort Boise", 160);
  57.         Landmark blueMountains     = new Landmark("Blue Mountains", 55, 125);
  58.         Fort     wallaWalla        = new Fort("Fort Walla Walla", 120);
  59.         Landmark dalles            = new Landmark("The Dalles", 100);
  60.                  
  61.         kansas.setWidth(620);
  62.         kansas.setDepth(4);
  63.         bigBlue.setWidth(300);
  64.         bigBlue.setDepth(6);
  65.         green.setWidth(400);
  66.         green.setDepth(20);
  67.         snake.setWidth(1000);
  68.         snake.setDepth(7);
  69.        
  70.         Object[] locations = new Object[] {
  71.             independence,
  72.             kansas,
  73.             bigBlue,
  74.             kearney,
  75.             chimneyRock,
  76.             laramie,
  77.             independenceRock,
  78.             southPass,
  79.             green,
  80.             bridger,
  81.             sodaSprings,
  82.             hall,
  83.             snake,
  84.             boise,
  85.             blueMountains,
  86.             wallaWalla,
  87.             dalles
  88.         };
  89.        
  90.     }
  91.  
  92.     /**
  93.      * This method is called from within the constructor to initialize the form.
  94.      * WARNING: Do NOT modify this code. The content of this method is always
  95.      * regenerated by the Form Editor.
  96.      */
  97.     @SuppressWarnings("unchecked")
  98.     // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
  99.     private void initComponents() {
  100.  
  101.         locationLabel = new javax.swing.JLabel();
  102.         toNextLabel = new javax.swing.JLabel();
  103.         healthLabel = new javax.swing.JLabel();
  104.         traveledLabel = new javax.swing.JLabel();
  105.         foodLabel = new javax.swing.JLabel();
  106.         dateLabel = new javax.swing.JLabel();
  107.         evaluateButton = new javax.swing.JButton();
  108.  
  109.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  110.  
  111.         locationLabel.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
  112.         locationLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
  113.         locationLabel.setText("LocationLabel");
  114.         locationLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  115.  
  116.         toNextLabel.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
  117.         toNextLabel.setText("Miles to next Landmark:");
  118.  
  119.         healthLabel.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
  120.         healthLabel.setText("Health:");
  121.  
  122.         traveledLabel.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
  123.         traveledLabel.setText("Miles Traveled:");
  124.  
  125.         foodLabel.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
  126.         foodLabel.setText("Food Left:");
  127.  
  128.         dateLabel.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
  129.         dateLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
  130.         dateLabel.setText("Date:");
  131.         dateLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  132.  
  133.         evaluateButton.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
  134.         evaluateButton.setText("Evaluate Situation");
  135.         evaluateButton.addActionListener(new java.awt.event.ActionListener() {
  136.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  137.                 evaluateButtonActionPerformed(evt);
  138.             }
  139.         });
  140.  
  141.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  142.         getContentPane().setLayout(layout);
  143.         layout.setHorizontalGroup(
  144.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  145.             .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  146.                 .addGap(115, 115, 115)
  147.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  148.                     .addComponent(toNextLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 373, Short.MAX_VALUE)
  149.                     .addComponent(healthLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  150.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 146, Short.MAX_VALUE)
  151.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  152.                     .addComponent(traveledLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 384, javax.swing.GroupLayout.PREFERRED_SIZE)
  153.                     .addComponent(foodLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 384, javax.swing.GroupLayout.PREFERRED_SIZE))
  154.                 .addGap(185, 185, 185))
  155.             .addGroup(layout.createSequentialGroup()
  156.                 .addGap(431, 431, 431)
  157.                 .addComponent(evaluateButton, javax.swing.GroupLayout.PREFERRED_SIZE, 279, javax.swing.GroupLayout.PREFERRED_SIZE)
  158.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  159.             .addGroup(layout.createSequentialGroup()
  160.                 .addGap(386, 386, 386)
  161.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  162.                     .addGroup(layout.createSequentialGroup()
  163.                         .addGap(6, 6, 6)
  164.                         .addComponent(dateLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 373, javax.swing.GroupLayout.PREFERRED_SIZE))
  165.                     .addComponent(locationLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 357, javax.swing.GroupLayout.PREFERRED_SIZE))
  166.                 .addGap(0, 0, Short.MAX_VALUE))
  167.         );
  168.         layout.setVerticalGroup(
  169.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  170.             .addGroup(layout.createSequentialGroup()
  171.                 .addGap(45, 45, 45)
  172.                 .addComponent(locationLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
  173.                 .addGap(5, 5, 5)
  174.                 .addComponent(dateLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
  175.                 .addGap(18, 18, 18)
  176.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  177.                     .addGroup(layout.createSequentialGroup()
  178.                         .addComponent(toNextLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
  179.                         .addGap(18, 18, 18)
  180.                         .addComponent(healthLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
  181.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 345, Short.MAX_VALUE)
  182.                         .addComponent(evaluateButton, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
  183.                         .addGap(38, 38, 38))
  184.                     .addGroup(layout.createSequentialGroup()
  185.                         .addComponent(traveledLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
  186.                         .addGap(18, 18, 18)
  187.                         .addComponent(foodLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
  188.                         .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
  189.         );
  190.  
  191.         pack();
  192.     }// </editor-fold>                        
  193.  
  194.     private void evaluateButtonActionPerformed(java.awt.event.ActionEvent evt) {                                              
  195.        
  196.         String s = locations[0].getName();ca
  197.     }                                              
  198.  
  199.     /**
  200.      * @param args the command line arguments
  201.      */
  202.     public static void main(String args[]) {
  203.         /* Set the Nimbus look and feel */
  204.         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  205.         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  206.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  207.          */
  208.         try {
  209.             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  210.                 if ("Nimbus".equals(info.getName())) {
  211.                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
  212.                     break;
  213.                 }
  214.             }
  215.         } catch (ClassNotFoundException ex) {
  216.             java.util.logging.Logger.getLogger(GameJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  217.         } catch (InstantiationException ex) {
  218.             java.util.logging.Logger.getLogger(GameJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  219.         } catch (IllegalAccessException ex) {
  220.             java.util.logging.Logger.getLogger(GameJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  221.         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  222.             java.util.logging.Logger.getLogger(GameJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  223.         }
  224.         //</editor-fold>
  225.  
  226.         /* Create and display the form */
  227.         java.awt.EventQueue.invokeLater(new Runnable() {
  228.             public void run() {
  229.                 new GameJFrame().setVisible(true);
  230.             }
  231.         });
  232.     }
  233.  
  234.     // Variables declaration - do not modify                    
  235.     private javax.swing.JLabel dateLabel;
  236.     private javax.swing.JButton evaluateButton;
  237.     private javax.swing.JLabel foodLabel;
  238.     private javax.swing.JLabel healthLabel;
  239.     private javax.swing.JLabel locationLabel;
  240.     private javax.swing.JLabel toNextLabel;
  241.     private javax.swing.JLabel traveledLabel;
  242.     // End of variables declaration                  
  243. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement