-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRollerCoasterProgram.java
More file actions
188 lines (166 loc) · 9.65 KB
/
RollerCoasterProgram.java
File metadata and controls
188 lines (166 loc) · 9.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
*/
/**
*
* @author rolly
*/
public class RollerCoasterProgram extends javax.swing.JFrame {
public RollerCoasterProgram() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
titleLabel = new javax.swing.JLabel();
heightLabel = new javax.swing.JLabel();
heartLabel = new javax.swing.JLabel();
backLabel = new javax.swing.JLabel();
heightBox = new javax.swing.JCheckBox();
heartBox = new javax.swing.JCheckBox();
backBox = new javax.swing.JCheckBox();
calculateButton = new javax.swing.JButton();
outputField = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("RollerCoasterRide");
titleLabel.setFont(new java.awt.Font("Bernard MT Condensed", 0, 48)); // NOI18N
titleLabel.setForeground(new java.awt.Color(128, 0, 0));
titleLabel.setText("Roller Coaster Ride");
heightLabel.setFont(new java.awt.Font("Serif", 0, 12)); // NOI18N
heightLabel.setForeground(new java.awt.Color(178, 34, 34));
heightLabel.setText("Are you in between 122cm - 188cm tall?");
heartLabel.setFont(new java.awt.Font("Serif", 0, 12)); // NOI18N
heartLabel.setForeground(new java.awt.Color(178, 34, 34));
heartLabel.setText("Do you have heart problems?");
backLabel.setFont(new java.awt.Font("Serif", 0, 12)); // NOI18N
backLabel.setForeground(new java.awt.Color(178, 34, 34));
backLabel.setText("Do you have back problems? ");
heightBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
heightBoxActionPerformed(evt);
}
});
backBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
backBoxActionPerformed(evt);
}
});
calculateButton.setFont(new java.awt.Font("Serif", 1, 12)); // NOI18N
calculateButton.setForeground(new java.awt.Color(178, 34, 34));
calculateButton.setText("Calculate");
calculateButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
calculateButtonActionPerformed(evt);
}
});
outputField.setEditable(false);
outputField.setFont(new java.awt.Font("Serif", 0, 12)); // NOI18N
outputField.setForeground(new java.awt.Color(178, 34, 34));
outputField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
outputFieldActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(25, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(titleLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 365, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(backLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 194, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(heartLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 194, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(heightLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 226, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(64, 64, 64)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(heightBox, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(heartBox, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(backBox, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE))))))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(49, 49, 49)
.addComponent(outputField, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(161, 161, 161)
.addComponent(calculateButton)))
.addGap(0, 0, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(titleLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(32, 32, 32)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(heightLabel)
.addComponent(heightBox))
.addGap(28, 28, 28)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(heartBox)
.addComponent(heartLabel))
.addGap(29, 29, 29)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(backBox)
.addComponent(backLabel))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(calculateButton)
.addGap(12, 12, 12)
.addComponent(outputField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(15, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void heightBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_heightBoxActionPerformed
}//GEN-LAST:event_heightBoxActionPerformed
private void outputFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_outputFieldActionPerformed
}//GEN-LAST:event_outputFieldActionPerformed
private void calculateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_calculateButtonActionPerformed
if (heightBox.isSelected() && !heartBox.isSelected() && !backBox.isSelected()){
outputField.setText("You are eligible to ride this roller coaster!");
}else {
outputField.setText("You are NOT eligible to ride this roller coaster.");
}
}//GEN-LAST:event_calculateButtonActionPerformed
private void backBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backBoxActionPerformed
}//GEN-LAST:event_backBoxActionPerformed
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(RollerCoasterProgram.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(RollerCoasterProgram.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(RollerCoasterProgram.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(RollerCoasterProgram.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new RollerCoasterProgram().setVisible(true);
}
});
}
private javax.swing.JCheckBox backBox;
private javax.swing.JLabel backLabel;
private javax.swing.JButton calculateButton;
private javax.swing.JCheckBox heartBox;
private javax.swing.JLabel heartLabel;
private javax.swing.JCheckBox heightBox;
private javax.swing.JLabel heightLabel;
private javax.swing.JTextField outputField;
private javax.swing.JLabel titleLabel;
// End of variables declaration//GEN-END:variables
}