/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Logan
*/
public class MidtermGUI extends javax.swing.JFrame {
/**
* Creates new form MidtermGUI
*/
public MidtermGUI() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
Printer = new javax.swing.JCheckBox();
Speakers = new javax.swing.JCheckBox();
Mouse = new javax.swing.JCheckBox();
Mousepad = new javax.swing.JCheckBox();
Headset = new javax.swing.JCheckBox();
Thumbdrive = new javax.swing.JCheckBox();
SelectPeriphMsg = new javax.swing.JLabel();
SelectDsrdShipping = new javax.swing.JLabel();
CostWShipping = new javax.swing.JButton();
CostWOutShipping = new javax.swing.JButton();
Output = new javax.swing.JTextField();
Ground = new javax.swing.JRadioButton();
Air = new javax.swing.JRadioButton();
FedEx = new javax.swing.JRadioButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
Printer.setText("Printer");
Printer.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
PrinterActionPerformed(evt);
}
});
Speakers.setText("Speakers");
Mouse.setText("Mouse");
Mousepad.setText("Mousepad");
Headset.setText("Headset");
Thumbdrive.setText("Thumb Drive");
SelectPeriphMsg.setText("Please Select Wanted Peripherals");
SelectDsrdShipping.setText("Please Select Desired Shipping Courier");
CostWShipping.setText("Cost w/ Shipping");
CostWShipping.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CostWShippingActionPerformed(evt);
}
});
CostWOutShipping.setText("Cost w/out Shipping");
CostWOutShipping.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CostWOutShippingActionPerformed(evt);
}
});
buttonGroup1.add(Ground);
Ground.setText("Ground");
buttonGroup1.add(Air);
Air.setText("Air");
buttonGroup1.add(FedEx);
FedEx.setText("FedEx");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(SelectDsrdShipping)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(CostWShipping)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(CostWOutShipping)
.addGap(48, 48, 48))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(SelectPeriphMsg)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(Printer)
.addGap(29, 29, 29))
.addGroup(layout.createSequentialGroup()
.addComponent(Mousepad)
.addGap(11, 11, 11)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(Headset)
.addComponent(Speakers))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(Mouse)
.addComponent(Thumbdrive))
.addGap(62, 62, 62))
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(Output)
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(FedEx)
.addComponent(Air)
.addComponent(Ground))
.addGap(0, 0, Short.MAX_VALUE))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Printer)
.addComponent(Speakers)
.addComponent(Mouse)
.addComponent(SelectPeriphMsg))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Mousepad)
.addComponent(Headset)
.addComponent(Thumbdrive))
.addGap(44, 44, 44)
.addComponent(SelectDsrdShipping)
.addGap(18, 18, 18)
.addComponent(Ground)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(Air)
.addGap(3, 3, 3)
.addComponent(FedEx)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(CostWShipping)
.addComponent(CostWOutShipping))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(Output, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void CostWShippingActionPerformed(java.awt.event.ActionEvent evt) {
}
private void CostWOutShippingActionPerformed(java.awt.event.ActionEvent evt) {
}
private void PrinterActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
public double calculateCost () {
//one unit
double theCost = 1;
double finalCost = 1;
double computerBase = 500;
double Printer = 35;
double Speakers = 75;
double mouse = 34;
double mousepad = 15;
double headset = 35;
double thumbdrive = 12;
return finalCost;
}
public double calculateCost (int computerAmounts, boolean shipping) {
double computerBase = 500;
//If statements for 1 Computer
//Calculations below.
{
if (Printer.isSelected()) {
double printer = 35;
}
if (Speakers.isSelected()) {
double speakers = 75;
}
if (Mouse.isSelected()) {
double mouse = 34;
}
if (Mousepad.isSelected()){
double mousepad = 15;
}
if (Headset.isSelected()) {
double headset = 35;
}
if (Thumbdrive.isSelected()) {
double thumbdrive = 12;
}
double finalCostOfComputer = computerBase+[B]printer+speakers+mouse+mousepad+headset;[/B]
//Computing cost of 1 computer.
return finalCostOfComputer;
}
}
public double getDiscountPercantage(int quantity, double discount) {
discount = .01;
return discount;
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see [url=http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html]How to Set the Look and Feel (The Java™ Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel)[/url]
*/
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(MidtermGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(MidtermGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(MidtermGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(MidtermGUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MidtermGUI().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JRadioButton Air;
private javax.swing.JButton CostWOutShipping;
private javax.swing.JButton CostWShipping;
private javax.swing.JRadioButton FedEx;
private javax.swing.JRadioButton Ground;
private javax.swing.JCheckBox Headset;
private javax.swing.JCheckBox Mouse;
private javax.swing.JCheckBox Mousepad;
private javax.swing.JTextField Output;
private javax.swing.JCheckBox Printer;
private javax.swing.JLabel SelectDsrdShipping;
private javax.swing.JLabel SelectPeriphMsg;
private javax.swing.JCheckBox Speakers;
private javax.swing.JCheckBox Thumbdrive;
private javax.swing.ButtonGroup buttonGroup1;
// End of variables declaration
}