Disini saya akan menunjukan bagaimana cara membuat program kasir bioskop sederhana, untuk memenuhi nilai tugas kuliah saya.
FlowChart
Hasil Program kasir bioskop sederhana.
Disini saya menggunakan MessageDialog
Masukan No tiket secara manual
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSlBE27KtXIGZjmI6sgPgvQTm85yuH7r946uDhcyPkHCdhVhCvjQ4CByW0W3z6B_Qmp-mtooFipfejjRU77Fp4rBe9JwFu4OqxNL_-GD2sxiT4TDkfXH8gb27C4-WkBSK8k3hyphenhyphenAEm6_gw/s320/1.png)
pilih Judul film
Pilih Hari
Pilih jenis tiket, dan akan muncul harga sesuai dengan pilihan hari dan jenis tiket
masukan jumlah tiket
dan muncul total bayar ketika sudah ditekan proses
Dan ini Soure codenya :)
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package program.tiket.bioskop;
import javax.swing.JOptionPane;
/**
*
* @author admin
*/
public class penjualan_tiket_bioskop extends javax.swing.JFrame {
/** Creates new form penjualan_tiket_bioskop */
public penjualan_tiket_bioskop() {
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() {
BG1 = new javax.swing.ButtonGroup();
jLabel2 = new javax.swing.JLabel();
NoTiket = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
Reguler = new javax.swing.JRadioButton();
UltraXD = new javax.swing.JRadioButton();
Gold = new javax.swing.JRadioButton();
UltraXDAtmos = new javax.swing.JRadioButton();
jLabel5 = new javax.swing.JLabel();
HargaSatuan = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
JumlahTiket = new javax.swing.JTextField();
btnproses = new javax.swing.JButton();
jLabel6 = new javax.swing.JLabel();
TotalBayar = new javax.swing.JTextField();
CmbFilm = new javax.swing.JComboBox<>();
jLabel7 = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
CmbHari = new javax.swing.JComboBox<>();
btnhapus = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBackground(new java.awt.Color(153, 0, 0));
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowActivated(java.awt.event.WindowEvent evt) {
formWindowActivated(evt);
}
});
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel2.setText("No Tiket");
NoTiket.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
NoTiket.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
NoTiketActionPerformed(evt);
}
});
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel3.setText("Jenis Tiket");
Reguler.setBackground(new java.awt.Color(255, 255, 255));
BG1.add(Reguler);
Reguler.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
Reguler.setText("Reguler");
Reguler.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
RegulerActionPerformed(evt);
}
});
BG1.add(UltraXD);
UltraXD.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
UltraXD.setText("Ultra XD");
UltraXD.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
UltraXDActionPerformed(evt);
}
});
BG1.add(Gold);
Gold.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
Gold.setText("Gold");
Gold.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
GoldActionPerformed(evt);
}
});
BG1.add(UltraXDAtmos);
UltraXDAtmos.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
UltraXDAtmos.setText("Ultra XD Atmos");
UltraXDAtmos.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
UltraXDAtmosActionPerformed(evt);
}
});
jLabel5.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel5.setText("Harga Satuan");
HargaSatuan.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
HargaSatuan.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
HargaSatuanActionPerformed(evt);
}
});
jLabel4.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel4.setText("Jumlah Tiket");
JumlahTiket.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
JumlahTiket.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
JumlahTiketActionPerformed(evt);
}
});
btnproses.setBackground(new java.awt.Color(51, 255, 0));
btnproses.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
btnproses.setText("Proses");
btnproses.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnprosesActionPerformed(evt);
}
});
jLabel6.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel6.setText("Total Bayar");
TotalBayar.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
TotalBayar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TotalBayarActionPerformed(evt);
}
});
CmbFilm.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmbFilmActionPerformed(evt);
}
});
jLabel7.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel7.setText("Judul Film");
jPanel1.setBackground(new java.awt.Color(0, 0, 0));
jLabel1.setBackground(java.awt.SystemColor.textHighlight);
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
jLabel1.setForeground(new java.awt.Color(153, 255, 0));
jLabel1.setText("Cinemaxx");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 204, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(90, 90, 90))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(24, 24, 24)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jLabel8.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel8.setText("Hari");
CmbHari.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CmbHariActionPerformed(evt);
}
});
btnhapus.setBackground(new java.awt.Color(0, 255, 0));
btnhapus.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
btnhapus.setText("Hapus");
btnhapus.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnhapusActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGap(28, 28, 28)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(jLabel7)
.addComponent(jLabel3)
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))
.addGap(90, 90, 90)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(HargaSatuan, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(Gold)
.addComponent(Reguler)
.addComponent(btnproses))
.addGap(32, 32, 32)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(UltraXDAtmos)
.addComponent(UltraXD)))
.addComponent(CmbFilm, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(CmbHari, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(NoTiket, javax.swing.GroupLayout.PREFERRED_SIZE, 189, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(btnhapus)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4)
.addComponent(jLabel6))
.addGap(98, 98, 98)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(JumlahTiket, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(TotalBayar, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addContainerGap(32, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(NoTiket, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(CmbFilm, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(CmbHari, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(28, 28, 28)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(Reguler)
.addComponent(UltraXDAtmos))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Gold)
.addComponent(UltraXD))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(HargaSatuan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(31, 31, 31)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(JumlahTiket, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(53, 53, 53))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(TotalBayar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(31, 31, 31)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnproses)
.addComponent(btnhapus))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void RegulerActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int Reguler;
if (CmbHari.getSelectedItem()=="Weekday"){
Object Harga = 30000;
HargaSatuan.setText(String.valueOf(Harga));
}
else if (CmbHari.getSelectedItem()=="Weekend"){
Object harga = 40000;
HargaSatuan.setText(String.valueOf(harga));
}
}
private void UltraXDActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (CmbHari.getSelectedItem()=="Weekday"){
Object Harga = 40000;
HargaSatuan.setText(String.valueOf(Harga));
}
else if (CmbHari.getSelectedItem()=="Weekend"){
Object harga = 50000;
HargaSatuan.setText(String.valueOf(harga));
}
}
private void UltraXDAtmosActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (CmbHari.getSelectedItem()=="Weekday"){
Object Harga = 50000;
HargaSatuan.setText(String.valueOf(Harga));
}
else if (CmbHari.getSelectedItem()=="Weekend"){
Object harga = 60000;
HargaSatuan.setText(String.valueOf(harga));
}
}
private void GoldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (CmbHari.getSelectedItem()=="Weekday"){
Object Harga = 60000;
HargaSatuan.setText(String.valueOf(Harga));
}
else if (CmbHari.getSelectedItem()=="Weekend"){
Object harga = 70000;
HargaSatuan.setText(String.valueOf(harga));
}
}
private void btnprosesActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int c = Integer.parseInt(HargaSatuan.getText());
int d = Integer.parseInt(JumlahTiket.getText());
int hasilnya = c*d;
TotalBayar.setText("Rp. "+hasilnya);
}
private void NoTiketActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void CmbFilmActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void HargaSatuanActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here
}
private void formWindowActivated(java.awt.event.WindowEvent evt) {
// TODO add your handling code here:
CmbFilm.addItem("-Pilih-");
CmbFilm.addItem("Avengers");
CmbFilm.addItem ("The Secret");
CmbFilm.addItem("Sajen");
CmbFilm.addItem("The Perfect Husband");
CmbHari.addItem("-pilih-");
CmbHari.addItem("Weekday");
CmbHari.addItem("Weekend");
}
private void CmbHariActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void JumlahTiketActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void TotalBayarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void btnhapusActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
NoTiket.setText(" ");
JumlahTiket.setText(" ");
HargaSatuan.setText(" ");
TotalBayar.setText(" ");
Reguler.setSelected(false);
UltraXD.setSelected(false);
Reguler.setEnabled(true);
UltraXD.setEnabled(true);
UltraXDAtmos.setSelected(false);
Gold.setSelected(false);
UltraXDAtmos.setEnabled(true);
Gold.setEnabled(true);
}
/**
* @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 http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
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(penjualan_tiket_bioskop.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(penjualan_tiket_bioskop.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(penjualan_tiket_bioskop.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(penjualan_tiket_bioskop.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() {
JOptionPane.showMessageDialog(null, "Selamat Datang Di Bioskop XXI");
new penjualan_tiket_bioskop().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.ButtonGroup BG1;
private javax.swing.JComboBox<String> CmbFilm;
private javax.swing.JComboBox<String> CmbHari;
private javax.swing.JRadioButton Gold;
private javax.swing.JTextField HargaSatuan;
private javax.swing.JTextField JumlahTiket;
private javax.swing.JTextField NoTiket;
private javax.swing.JRadioButton Reguler;
private javax.swing.JTextField TotalBayar;
private javax.swing.JRadioButton UltraXD;
private javax.swing.JRadioButton UltraXDAtmos;
private javax.swing.JButton btnhapus;
private javax.swing.JButton btnproses;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JPanel jPanel1;
// End of variables declaration
}
Tidak ada komentar:
Posting Komentar