Kamis, 03 November 2011

TUGAS OOP (PROGRAM CAFE) DENGAN NETBEANS

ASSALAMUALAIKUM WARAHMATULLAHI WABARAKATUH



TUGAS FORM CAFÉ DENGAN MENGGUNAKAN  NETBEANS
Tampilan  form menu

Tampilan submenu café


Coding tampilan menu

Bagaian 1
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
        new cafe().setVisible(true);
    }                                         

Bagian 2
public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new tampmenu().setVisible(true);
            }
        });
    }

Coding submenu café
Bagian 1
public class cafe extends javax.swing.JFrame {
      String namamakanan,namaminuman;
int hargamakanan,hargaminuman,total,bayar,kembalian,kembali;

bagian 2
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        dispose();
    }                
Bagian 3
  private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
         cbminuman.setSelectedIndex(0);
         cbmakanan.setSelectedIndex(0);
         txthmin.setText("");
         txthmak.setText("");
         txttotal.setText("");
         txtbayar.setText("");
         txtkembali.setText("");
    }                                        

Bagian 4

  private void cbminumanActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
               String namaminuman;
namaminuman=cbminuman.getSelectedItem().toString();
if(namaminuman.equalsIgnoreCase("Jus"))
{
hargaminuman=5000;
}
else if(namaminuman.equalsIgnoreCase("Susu"))
{
hargaminuman=6000;

}
txthmin.setText(String.valueOf(hargaminuman));
    }                                        

    private void cbmakananActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
                       String namamakanan;
namamakanan=cbmakanan.getSelectedItem().toString();
if(namamakanan.equalsIgnoreCase("Burger"))
{
hargamakanan=15000;
}
else if(namamakanan.equalsIgnoreCase("Kacang"))
{
hargamakanan=5000;

}
txthmak.setText(String.valueOf(hargamakanan));
    }                                        

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
        total=hargamakanan+hargaminuman;
        txttotal.setText(String.valueOf(total));
    }                                       

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { 
//agus si3                                      
        // TODO add your handling code here:
                bayar=Integer.parseInt(txtbayar.getText());
                 total=Integer.parseInt(txttotal.getText());
               kembalian=bayar-total;
        txtkembali.setText(String.valueOf(kembalian));

    }                                      
Sekian terimakasih alias matur nuhun alian matur tankyou alias sukron katsir……..

Semoga bermanfaat

Takbir………!!!!!!!!!

ALLOHUAKBAR……..!!!!!!!!

1 komentar: