Senin, 15 Maret 2021

Membangun Dasar Program Java Berorientasi Objek


Dasar Program Java Berorientasi Objek


 
 
ANALISIS APLIKASI BISNIS BAHARI



Selamat datang semuanya! Adapun dalam konteks pembahasan kita kali ini adalah perihal menganalisis dan membangun aplikasi orisinil berorientasi objek menggunakan bahasa program Java. Kasus yang penyusun dan tim gunakan adalah Aplikasi Bisnis Bahari "Fishceanid": Aplikasi Sistem Marketplace Jual - Beli Ikan Tangkap & Ikan Hias. Jadi kurang lebih diharapkan aplikasi ini dapat memenuhi fungsinya untuk menjadi media dalam mempertemukan penjual pihak pertama (nelayan & pembudidaya ikan) kepada pembeli. Adapun hasil analisis yang didapatkan adalah sebagai berikut :
 
Target Sub-Menu Pertama

            Aplikasi Fischeanid merupakan aplikasi yang berfokus pada penyediaan jasa jual-beli layaknya marketplace, tentu dengan begitu akan memiliki banyak sub-menu yang perlu dibangun. Namun, dalam kesempatan analisa dan praktik pertama kali ini kami berfokus pada proses pertama yakni user mendaftarkan tokonya untuk terlibat dalam market utama. Adapun user disini adalah penjual.

 

Source Code & Class Provider

§   Package : pkgFishceanid

§   Aplikasi   : appFischeanid.java

§   Class       : cPenjual, cIkan, cToko

Adapun detail sementara atribut dari setiap class tersebut adalah penjual memiliki setidaknya Identification Penjual sebagai kunci utama mereka diikuti dengan nama, kontak, dan alamat. Kedua kelas Ikan setidaknya memiliki Kode Ikan, Nama, Spesies, Tipe, & Jumlah. Kemudian toko memiliki Kode Toko sebagai kunci utamanya diikuti dengan Nama, cIkan, Deskripsi, dan Alamat.

§   Kelas Penjual   : id_pjual, nama_pjual, kontak_pjual, & Alamat_pjual.

§   Kelas Ikan        : kd_Ikan, nama_Ikan, spesies_ikan, tipe_ikan, jumlah_ikan.

§  Kelas Toko    : kd_toko, nama_toko, suplai_toko, desk_toko, &                                                               alamat_toko.

 

§   MAIN
 
import java.util.Scanner;

public class appFishceanid {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int pilih=0;
        cPenjual pjl = null; //Object Penjual
        cToko tko = null; //Object Toko
        cIkan ikn = null; //Object Ikan

        do {
            System.out.println("Sistem Fishceanid");
            System.out.println("1. Home");
            System.out.println("2. Market");
            System.out.println("3. Shipment");
            System.out.println("4. About");
            System.out.println("5. Close");
            System.out.print("Opsi = ");
            pilih = scan.nextInt();

            System.out.println("");

            switch(pilih) {
                case 1 :
                    System.out.println("Home");
                    break;

                case 2 :
                    System.out.println("Menu Market");
                        System.out.println("1. Penjual");
                        System.out.println("2. Toko");
                        System.out.println("3. Ikan");
                        System.out.print("Opsi = ");
                        int pilih2 = scan.nextInt();

                        System.out.println("");

                        switch(pilih2) {
                            case 1 :
                                System.out.println("Tentang Penjual");
                                System.out.println("1. Tambah");
                                System.out.println("2. Update");
                                System.out.println("3. Lihat");
                                System.out.println("4. Hapus");
                                System.out.println("5. Query");
                                System.out.print("Pilihannya : ");
                                int pilih3 = scan.nextInt();

                                System.out.println("");

                                switch(pilih3) {
                                    case 1 :
                                        System.out.println("Menambahkan Data Penjual");
                                        System.out.print("ID Penjual = ");
                                        String idpj = scan.next();

                                        System.out.print("Nama = ");
                                        scan = new Scanner(System.in);
                                        String npj = scan.nextLine();

                                        System.out.print("Kontak = ");
                                        String kpj = scan.next();

                                        System.out.print("Alamat = ");
                                        String apj = scan.next();

                                        pjl = new cPenjual(idpj, npj, kpj, apj);
                                        System.out.println("Data Penjual Berhasil Ditambahkan");
                                        break;

                                    case 2 :
                                        System.out.println("Memperbarui Data Penjual");
                                        System.out.print("ID = ");
                                        idpj = scan.next();

                                        if(pjl!=null && pjl.getid_pjual().equalsIgnoreCase(idpj)) {
                                            System.out.print("Nama Baru = ");
                                            scan = new Scanner(System.in);
                                            npj = scan.nextLine();

                                            System.out.print("Kontak Baru = ");
                                            scan = new Scanner(System.in);
                                            kpj = scan.nextLine();

                                            System.out.print("Alamat Baru = ");
                                            scan = new Scanner(System.in);
                                            apj = scan.nextLine();

                                            pjl.setnama_pjual(npj);
                                            pjl.setkontak_pjual(kpj);
                                            pjl.setalamat_pjual(apj);

                                            System.out.println("Data Penjual Berhasil Diupdate");
                                        }
                                        else System.out.println("Data Penjual Tidak Ditemukan");
                                        break;

                                    case 3 :
                                        System.out.println("Melihat Data Penjual");
                                        if(pjl!=null) {
                                            System.out.println("ID = " + pjl.getid_pjual());
                                            System.out.println("Nama = " + pjl.getnama_pjual());
                                            System.out.println("Kontak = " + pjl.getkontak_pjual());
                                            System.out.println("Alamat = " + pjl.getalamat_pjual());
                                        }
                                        else System.out.println("Data Penjual Kosong");
                                        break;

                                    case 4 :
                                        System.out.println("Menghapus Data Penjual");
                                        System.out.print("ID Penjual = ");
                                        idpj = scan.next();
                                        if(pjl!=null && pjl.getid_pjual().equalsIgnoreCase(idpj)) {
                                            System.out.println("Data Penjual Telah Ditemukan");
                                            System.out.println("Apakah Yakin Ingin Dihapus? 1.Yes, 2.No");
                                            System.out.print("Opsi : ");
                                            int menghapus = scan.nextInt();
                                            
                                            if(menghapus==1) {
                                                pjl=null;
                                                System.out.println("Data Penjual Berhasil Dihapus");
                                            }
                                            else System.out.println("Data Penjual Tidak Dihapus");
                                        }
                                        else System.out.println("Data Penjual yang Dimaksud Tidak Ditemukan");
                                        break;

                                    case 5 :
                                        System.out.println("Query Data Penjual");
                                        if(pjl!=null) {
                                            System.out.println(pjl.toString());
                                        }
                                        else System.out.println("Data Penjual Kosong");

                                        break;
                                        default : System.out.println("Tidak Bisa Melakukan Hal Tersebut");
                                }
                                break;


                            case 2 :
                                System.out.println("Tentang Toko");
                                System.out.println("1. Tambah");
                                System.out.println("2. Update");
                                System.out.println("3. Lihat Toko");
                                System.out.println("4. Lihat Identitas Pemilik");
                                System.out.println("5. Lihat Detail Produk Toko");
                                System.out.println("6. Hapus");
                                System.out.println("7. Query");
                                System.out.print("Opsional : ");
                                int pilih4 = scan.nextInt();

                                System.out.println("");

                                switch(pilih4) {
                                    case 1 :
                                        System.out.println("Menambah Data Toko");
                                        System.out.print("ID Toko = ");
                                        String kdtk = scan.next();

                                        System.out.print("Nama Toko = ");
                                        scan = new Scanner(System.in);
                                        String ntk = scan.nextLine();

                                        System.out.print("Suplai = ");
                                        String stk = scan.next();

                                        System.out.print("Deskripsi Toko = ");
                                        scan = new Scanner(System.in);
                                        String desktk = scan.nextLine();

                                        System.out.print("Alamat Toko = ");
                                        scan = new Scanner(System.in);
                                        String atk = scan.next();

                                        tko = new cToko(kdtk, ntk, stk, desktk, atk);
                                        System.out.println("Data Toko Berhasil Ditambahkan");
                                        break;


                                    case 2 :
                                        System.out.println("Memperbarui Data Toko");
                                        System.out.print("Kode = ");
                                        kdtk = scan.next();

                                        if(tko!=null && tko.getkd_toko().equalsIgnoreCase(kdtk)) {
                                            System.out.print("Nama Baru Toko = ");
                                            scan = new Scanner(System.in);
                                            ntk = scan.nextLine();

                                            System.out.print("Suplai Baru = ");
                                            scan = new Scanner(System.in);
                                            stk = scan.nextLine();

                                            System.out.print("Deskripsi Baru = ");
                                            scan = new Scanner(System.in);
                                            desktk = scan.nextLine();

                                            System.out.print("Alamat Baru Toko = ");
                                            scan = new Scanner(System.in);
                                            atk = scan.nextLine();

                                            tko.setnama_toko(ntk);
                                            tko.setsuplai_toko(stk);
                                            tko.setdesk_toko(desktk);
                                            tko.setalamat_toko(atk);

                                            System.out.println("Data Toko Berhasil Diupdate");
                                        }
                                        else System.out.println("Data Toko Tidak Ditemukan");
                                        break;

                                    case 3 :
                                        System.out.println("Melihat Data Toko");
                                        if(tko!=null) {
                                            System.out.println("Kode Toko = " + tko.getkd_toko());
                                            System.out.println("Nama Toko = " + tko.getnama_toko());
                                            System.out.println("Suplai Toko = " + tko.getsuplai_toko());
                                            System.out.println("Deskripsi Toko = " + tko.getdesk_toko());
                                            System.out.println("Alamat Toko = " + tko.getalamat_toko());
                                        }
                                        else System.out.println("Data Toko Tidak Tersedia");
                                        break;

                                    case 4 :
                                        System.out.println("Melihat Data Pemilik");
                                        if(pjl!=null) {
                                            System.out.println("ID Pemilik = " + pjl.getid_pjual());
                                            System.out.println("Nama Pemilik = " + pjl.getnama_pjual());
                                            System.out.println("Kontak Pemilik = " + pjl.getkontak_pjual());
                                            System.out.println("Alamat Pemilik = " + pjl.getalamat_pjual());
                                        }
                                        else System.out.println("Data Pemilik Kosong");
                                        break;

                                    case 5 :
                                        System.out.println("Melihat Data Ikan Toko");
                                        if(ikn!=null) {
                                            System.out.println("Kode Ikan di Toko = " + ikn.getkd_ikan());
                                            System.out.println("Nama Ikan di Toko = " + ikn.getnama_ikan());
                                            System.out.println("Spesies Ikan di Toko = " + ikn.getspesies_ikan());
                                            System.out.println("Tipe Ikan di Toko = " + ikn.gettipe_ikan());
                                            System.out.println("Jumlah Ikan = " + ikn.getjumlah_ikan());
                                        }
                                        else System.out.println("Data Toko Kosong");
                                        break;

                                    case 6 :
                                        System.out.println("Menghapus Data Toko");
                                        System.out.print("Kode Toko = ");
                                        kdtk = scan.next();
                                        if(tko!=null && tko.getkd_toko().equalsIgnoreCase(kdtk)) {
                                            System.out.println("Data Toko Telah Ditemukan");
                                            System.out.println("Apakah Yakin Ingin Dihapus? 1.Yes, 2.No");
                                            System.out.print("Opsi : ");
                                            int menghapus = scan.nextInt();
                                            
                                            if(menghapus==1) {
                                                tko=null;
                                                System.out.println("Data Toko Berhasil Dihapus");
                                            }
                                            else System.out.println("Data Toko Tidak Dihapus");
                                        }
                                        else System.out.println("Data Toko yang Dimaksud Tidak Ditemukan");

                                        break;

                                    case 7 :
                                        System.out.println("Query Data Toko");
                                        if(tko!=null) {
                                            System.out.println(tko.toString());
                                        }
                                        else System.out.println("Data Toko Kosong");

                                        break;
                                        default : System.out.println("Tidak Bisa Melakukan Hal Itu");

                                    }
                                    break;


                            case 3 :
                                System.out.println("Tentang Ikan");
                                System.out.println("1. Tambah Data Ikan");
                                System.out.println("2. Update Data Ikan");
                                System.out.println("3. Lihat Data Ikan");
                                System.out.println("4. Hapus Data Ikan");
                                System.out.println("5. Query Data Ikan");
                                System.out.print("Pilihannya : ");
                                int pilih5 = scan.nextInt();

                                System.out.println("");
                                
                                switch(pilih5) {
                                    case 1 :
                                        System.out.println("Menambah Data Ikan");
                                        System.out.print("Kode Ikan = ");
                                        String kdik = scan.next();

                                        System.out.print("Nama Ikan = ");
                                        scan = new Scanner(System.in);
                                        String namik = scan.nextLine();

                                        System.out.print("Spesies Ikan = ");
                                        String spik = scan.nextLine();

                                        System.out.print("Tipe Ikan = ");
                                        scan = new Scanner(System.in);
                                        String tipik = scan.nextLine();

                                        ikn = new cIkan(kdik, namik, spik, tipik);
                                        System.out.println("Data Ikan Berhasil Ditambahkan");

                                        break;

                                    case 2 :
                                        System.out.println("Memperbarui Data Ikan");
                                        System.out.print("Kode Ikan yang Diperbarui = ");
                                        kdik = scan.next();

                                        if(ikn!=null && ikn.getkd_ikan().equalsIgnoreCase(kdik)) {
                                            System.out.print("Nama Baru Ikan = ");
                                            scan = new Scanner(System.in);
                                            namik = scan.nextLine();

                                            System.out.print("Spesies Baru Ikan = ");
                                            scan = new Scanner(System.in);
                                            spik = scan.nextLine();

                                            System.out.print("Tipe Baru Ikan = ");
                                            scan = new Scanner(System.in);
                                            tipik = scan.nextLine();

                                            System.out.print("Jumlah Baru Ikan = ");
                                            scan = new Scanner(System.in);
                                            int jumik = scan.nextInt();

                                            ikn.setnama_ikan(namik);
                                            ikn.setspesies_ikan(spik);
                                            ikn.settipe_ikan(tipik);
                                            ikn.setjumlah_ikan(jumik);

                                            System.out.println("Data Ikan Berhasil Diupdate");
                                        }
                                        else System.out.println("Data Ikan Tidak Ditemukan");

                                        break;

                                    case 3 :
                                        System.out.println("Melihat Data Ikan");
                                        if(ikn!=null) {
                                            System.out.println("Kode Ikan = " + ikn.getkd_ikan());
                                            System.out.println("Nama Ikan = " + ikn.getnama_ikan());
                                            System.out.println("Spesies Ikan = " + ikn.getspesies_ikan());
                                            System.out.println("Tipe Ikan = " + ikn.gettipe_ikan());
                                            System.out.println("Jumlah Ikan = " + ikn.getjumlah_ikan());
                                        }
                                        else System.out.println("Data Ikan Kosong");

                                        break;

                                    case 4 :
                                        System.out.println("Menghapus Data Ikan");
                                        System.out.print("Kode Ikan yang Ingin Dihapus = ");
                                        kdik = scan.next();
                                        if(ikn!=null && ikn.getkd_ikan().equalsIgnoreCase(kdik)) {
                                            System.out.println("Data Ikan Telah Ditemukan");
                                            System.out.println("Apakah Yakin Ini Dihapus? 1.Yes, 2.No");
                                            System.out.print("Opsional : ");
                                            int menghapus = scan.nextInt();
                                            
                                            if(menghapus==1) {
                                                ikn=null;
                                                System.out.println("Data Ikan Berhasil Dihapus");
                                            }
                                            else System.out.println("Data Ikan Tidak Dihapus");
                                        }
                                        else System.out.println("Data Ikan yang Dimaksud Tidak Ditemukan");

                                        break;

                                    case 5 :
                                        System.out.println("Query Data Ikan");
                                        if(ikn!=null) {
                                            System.out.println(ikn.toString());
                                        }
                                        else System.out.println("Data Ikan Kosong");

                                        break;
                                        default : System.out.println("Tidak Bisa Melakukan Hal Itu");
                                }

                                break;
                                default : System.out.println("Opsi Tersebut Tidak Tersedia");
                        }
                    break;


                case 3 :
                    System.out.println("Menu Shipment");
                    break;
                case 4 :
                    System.out.println("Menu About");
                    break;
                case 5 :
                    System.out.println("Terimakasih");
                    break;

                    default : System.out.println("Opsi Tersebut Tidak Tersedia");
            }
            System.out.println("");
        }while(pilih!=5);
            System.out.println("Sampai Jumpa");
    }
}


§   cPENJUAL
 
public class cPenjual {
    private String id_pjual;
    private String nama_pjual;
    private String kontak_pjual;
    private String alamat_pjual;
 
    cPenjual(String idpjString npjString kpjString apj) {
        id_pjual=idpj; nama_pjual=npj; kontak_pjual=kpj; 
    alamat_pjual=apj;
    }
    public void setid_pjual(String idpj) {
        id_pjual=idpj;
    }
    public void setnama_pjual(String npj) {
        nama_pjual=npj;
    }
    public void setkontak_pjual(String kpj) {
        kontak_pjual=kpj;
    }
    public void setalamat_pjual(String apj) {
        alamat_pjual=apj;
    }
    public String getid_pjual() {
        return id_pjual;
    }
    public String getnama_pjual() {
        return nama_pjual;
    }
    public String getkontak_pjual() {
        return kontak_pjual;
    }
    public String getalamat_pjual() {
        return alamat_pjual;
    }
    public String toString() {
        return id_pjual+" "+nama_pjual+" "+kontak_pjual+" "+ 
    alamat_pjual;
    }
}


§   cIKAN
 
public class cIkan {
    private String kd_ikan;
    private String nama_ikan;
    private String spesies_ikan;
    private String tipe_ikan;
    private int jumlah_ikan;
 
    cIkan(String kdikString namikString spikString tipik) {
        kd_ikan=kdiknama_ikan=namikspesies_ikan=spik
        tipe_ikan=tipik;
    }
    public void setkd_ikan(String kdik) {
        kd_ikan=kdik;
    }
    public void setnama_ikan(String namik) {
        nama_ikan=namik;
    }
    public void setspesies_ikan(String spik) {
        spesies_ikan=spik;
    }
    public void settipe_ikan(String tipik) {
        tipe_ikan=tipik;
    }
    public void setjumlah_ikan(int jumik) {
        jumlah_ikan=jumik;
    }
    public String getkd_ikan() {
        return kd_ikan;
    }
    public String getnama_ikan() {
        return nama_ikan;
    }
    public String getspesies_ikan() {
        return spesies_ikan;
    }
    public String gettipe_ikan() {
        return tipe_ikan;
    }
    public int getjumlah_ikan() {
        return jumlah_ikan;
    }
    public String toString() {
        return kd_ikan+""+nama_ikan+""+spesies_ikan+""+tipe_ikan+""+ 
    jumlah_ikan;
    }
}
 
 
§   cTOKO
 
public class cToko {
    public String kd_toko;
    public String nama_toko;
    public String suplai_toko;
    public String desk_toko;
    public String alamat_toko;

    cToko(String kdtkString ntkString stkString desktkString atk
    {
        kd_toko=kdtknama_toko=ntksuplai_toko=stkdesk_toko=desktk 
        alamat_toko=atk;
    }
    public void setkd_toko(String kdtk) {
        kd_toko=kdtk;
    }
    public void setnama_toko(String ntk) {
        nama_toko=ntk;
    }
    public void setsuplai_toko(String stk) {
        suplai_toko=stk;
    }
    public void setdesk_toko(String desktk) {
        desk_toko=desktk;
    }
    public void setalamat_toko(String atk) {
        alamat_toko=atk;
    }
    public String getkd_toko() {
        return kd_toko;
    }
    public String getnama_toko() {
        return nama_toko;
    }
    public String getsuplai_toko() {
        return suplai_toko;
    }
    public String getdesk_toko() {
        return desk_toko;
    }
    public String getalamat_toko() {
        return alamat_toko;
    }
    public String toString() {
        return kd_toko+""+nama_toko+""+suplai_toko+""+desk_toko+""+
    alamat_toko;
    }
}
 
 
Tentunya program ini masih memiliki kekurangan, semoga bermanfaat & terimakasih ::)






Tidak ada komentar:

Posting Komentar