Senin, 03 April 2017

Mesin Antrian Bank




MESIN ANTRIAN BANK

Mesin pencetak antrian bank adalah system yang berfungsi untuk mengelola nomor urut antrian nasabah bank. Mesin ini mempunyai fungsi, mempermudah teller dan customer service, atau layanan lain pada bank tersebut, memanggil nasabah dan melayani sesuai dengan keperluan nasabah, pada masing-masing layanan.

Berikut adalah rancangan awalnya:


kemudian direvisi menjadi ini:


souce code nya adalah:

Class pegawai:
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
import javax.swing.*;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.awt.*;
import java.awt.event.*;


public class pegawai extends JFrame { 
    private int awalptel=0,awalpcs=0;
    JButton btn = new JButton("Costumer Service");  
    JButton btn2 = new JButton("TELLER");
        TextField text1 = new TextField(30);
        TextField text2 = new TextField(30);
        TextField text3 = new TextField(30);
    URL defaultSound;
    public static Clip clip;
    public static AudioInputStream audioInputStream; 
    antripeg x = new antripeg();
            public pegawai(String url) {
        super(url);
        setLayout(new FlowLayout());
        try {  
            JPanel jp = new JPanel();
            defaultSound = new URL (url);
            jp.add(btn);
            jp.add(btn2);
            add(text1);
            add(text2);
            add(text3);
            getContentPane().add(jp);
            pack();     
           
            btn.addActionListener(new ActionListener() {             
                public void actionPerformed(ActionEvent e) { 
                    play();
                        text1.setText("No.antrian= " + x.urutanp_cs(awalpcs) +"");
                        text2.setText("CUSTOMER SERVICE");
                        text3.setText("SILAHKAN MENUJU LOKET");
                        awalpcs++;
                }
            });
            
            btn2.addActionListener(new ActionListener() {             
               
                public void actionPerformed(ActionEvent e) { 
          
                    play();  
                    text1.setText("No.antrian= " + x.urutanp_tel(awalptel) +"");
                        text2.setText("TELLER");
                        text3.setText("SILAHKAN MENUJU LOKET");
                        awalptel++;
                }
            });
          
}
        catch (MalformedURLException ex) {
            Logger.getLogger(pegawai.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void play() {
        try {
            audioInputStream = AudioSystem.getAudioInputStream(defaultSound);

            try {
                clip = AudioSystem.getClip();
                clip.open(audioInputStream);
                clip.start();

            } catch (LineUnavailableException e) {
            }

        } catch (UnsupportedAudioFileException | IOException e) {
        }
    }
}

Class antripeg:
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
public class antripeg
{
    private int no_cs,no_tel;

  
    public int urutanp_tel(int awal)
    {
        no_tel=awal;
        no_tel++;
        return no_tel;
        
    }
      
        public int urutanp_cs(int awal)
    {
        no_cs=awal;
        no_cs++;
        return no_cs;
    }
        
}

Class nasabah:
import javax.swing.JOptionPane;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;


public class nasabah extends JFrame { 
    int awaltel=0,awalcs=0;
    JButton btn = new JButton("Costumer Service");  
    JButton btn2 = new JButton("TELLER");
    antrinas y = new antrinas();
    
            public nasabah() {
        setLayout(new FlowLayout());
            JPanel jp = new JPanel();
            jp.add(btn);
            jp.add(btn2);
          
            getContentPane().add(jp);
            pack();     
           
            btn.addActionListener(new ActionListener() {             
                public void actionPerformed(ActionEvent e) { 
                    JOptionPane.showMessageDialog(null,
                    " Nomor Antrian Anda Adalah "+y.urutan_cs(awalcs)+"\n Sisa Antrian Adalah "+y.sisacs()+"\n "+y.getTanggal()+"'\n Customer Service\n Mohon Menunggu",
                    "STRUK ANTRIAN",JOptionPane.PLAIN_MESSAGE);
                    awalcs++;
                }
            });
            
            btn2.addActionListener(new ActionListener() {             
               
                public void actionPerformed(ActionEvent e) { 
               JOptionPane.showMessageDialog(null,
                    " Nomor Antrian Anda Adalah "+y.urutan_tel(awaltel)+"\n Sisa Antrian Adalah "+y.sisatel()+"\n "+y.getTanggal()+"\n TELLER\n Mohon Menunggu",
                    "STRUK ANTRIAN",JOptionPane.PLAIN_MESSAGE);
                    awaltel++;
                }
            });

    }

  
    }

Class antrinas:
 import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
public class antrinas
{
    private int no_tel,sisa_tel,no_cs,sisa_cs;

    public int urutan_tel(int awal)
    {
        no_tel=awal;
        no_tel++;
        return no_tel;
        
    }
            
     public String getTanggal()
    {
            
            DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy H:mm:ss");
            Date date = new Date();
            return dateFormat.format(date);
    }
        
        
    public int sisatel()
    {
        sisa_tel=100-no_tel;
        return sisa_tel;
    }

    public int urutan_cs(int awal)
    {
        no_cs=awal;
        no_cs++;
        return no_cs;
    }
        
    
    public int sisacs()
    {
        sisa_cs=100-no_cs;
        return sisa_cs;
    }
}

Class AL:
 import java.awt.*;
import java.awt.event.*;

public class AL extends Frame {
        Button b;
        Button a;

        public static void main(String[] args) {
                AL myWindow = new AL("ANTRI BANK");
                myWindow.setSize(500,200);
                myWindow.setVisible(true);
        }

        public AL(String title) {

                super(title);
                setLayout(new FlowLayout());
                a = new Button("PEGAWAI");
                b = new Button("NASABAH");
                add(a);add(b);
               
                
                a.addActionListener(new ActionListener(){             
                
                public void actionPerformed(ActionEvent e) {
                       
                pegawai t = new pegawai("file:D:/bell.wav");/*file audio yang diputar*/
                t.setVisible(true);
                t.setSize(300,300);
                t.setLocation(100,200);
                    }
                 });
                
                
          b.addActionListener(new ActionListener(){             
                
                public void actionPerformed(ActionEvent e) 
                  {
            
                nasabah s = new nasabah();
                s.setVisible(true);
                s.setSize(300,200);
                s.setLocation(100,200);
                    }
                 });
                }

    }

Output:











Hasil dari PEGAWAI:

-TELLER:
-Customer Service:

Hasil dari NASABAH:
-
-TELLER:












-Customer Service:




Tidak ada komentar:

Posting Komentar