Top Ad unit 728 × 90

Latest News

Internet

Contoh Aplikasi Insert, Update, Delete Penjualan Smartphone atau HP dengan Java NetBeans IDE

Berikut contoh aplikasi CRUD preorder smartphone Oppo F4s dengan Java Netbeans : 

Java merupakan suatu bahasa pemrograman yang banyak digunakan oleh para programer di dunia. Contohnya aplikasi CRUD.

CRUD adalah Create, Read,  Update, dan Delete. Aplikasi CRUD merukan aplikasi yang lengkap yang sering digunakan oleh  para programer untuk di jadikan contoh.

Berkut contoh aplikasi CRUD dengan menggunakan Java Netbeans.

Copy script dibawah :
package aplikasi_preorder_hp;
//Kuman Merah
//https://kumanmerah.blogspot.co.id/
//Semoga Bermanfaat
import java.util.Scanner;

class node {

    node next;
    node prev;
    int data;
    String nama;
    node pesanan;

    node(int databaru, String namabaru, node pesanan) {
        this.data = databaru;
        this.nama = namabaru;
        this.pesanan = pesanan;
        this.next = null;
        this.prev = null;
    }

    void setprev(node lain) {
        this.prev = lain;
        lain.next = this;
    }

    void setnext(node lain) {
        this.next = lain;
        lain.prev = this;
    }
}

class linkedlist {

    node head;
    node tail;

    linkedlist() {
        this.head = null;
        this.tail = null;
    }

    void print() {
        node current = head;
        while (current != null) {
            System.out.print(current.data + " ");
            current = current.next;
        }
        System.out.println("");
    }

    void push(node baru) {
        if (head == null) {
            head = baru;
            tail = baru;
        } else {
            tail.setnext(baru);
            tail = baru;
        }
    }

    void insert(node baru) {
        if (head == null) {
            head = baru;
            tail = baru;
        } else if (baru.data <= head.data) {
            head.setprev(baru);
            head = baru;
        } else if (baru.data >= tail.data) {
            tail.setnext(baru);
            tail = baru;
        } else {
            node current = head;
            while (current != null) {
                if (current.data >= baru.data) {
                    node barunext = current;
                    node baruprev = current.prev;
                    baru.setnext(barunext);
                    baru.setprev(baruprev);
                    break;
                }
                current = current.next;

            }
        }

    }

    node find(int data) {
        node cur = head;
        while (cur != null) {
            if (cur.data == data) {
                System.out.println("ada");
                return cur;
            }
            cur = cur.next;
        }
        System.out.println("gak ketemu");
        return null;
    }

    void delete(node hapus) {
        node cur = head;
        while (cur != null) {
            if (cur.data == hapus.data) {
                System.out.println(hapus.data + " terhapusk");
                if (head == tail && head.data == hapus.data) {
                    head = null;
                    tail = null;
                } else if (hapus.data == head.data) {
                    head = head.next;
                    head.prev = null;
                } else if (hapus.data == tail.data) {
                    tail = tail.prev;
                    tail.next = null;
                } else {
                    node ha = hapus.prev;
                    node pus = hapus.next;
                    hapus = null;
                    ha.setnext(pus);
                }
                break;
            }
            cur = cur.next;
        }
        System.out.println("gaada yg kehapus..");
    }

    int jumlah() {
        node jumlah = head;
        int jml = 0;
        while (jumlah != null) {
            jml++;
            jumlah = jumlah.next;
        }
        return jml;
    }

    public node qpop() { // 5 orang
        // TODO: write the code, pop node (queue), return it
        if (head == null) {
            System.out.println("LinkedList Kosong");
            return null;
        } else if (head == tail) {
            node temp = head;
            head = null;
            tail = null;
            return temp;
        } else {
            node temp = head;
            head = head.next;
            head.prev = null;
            temp.next = null;
            return temp;
        }
    }

    public node spop() { // 5 orang
        if (head == tail) {
            node temp = tail;
            tail = null;
            head = null;
            return temp;
        } else if (tail == null) {
            System.out.println("LinkedList Kosong");
            return null;
        } else {
            node temp = tail;
            tail = tail.prev;
            tail.next = null;
            temp.prev = null;
            return temp;
        }
    }
}

public class Aplikasi_preorder_hp {

    public static void main(String[] args) {
        linkedlist a = new linkedlist();
        linkedlist pelanggan = new linkedlist();
        linkedlist hitam = new linkedlist();
        linkedlist putih = new linkedlist();
        System.out.println("APLIKASI PREORDER OPPO F4s");
        int pilihan = 0;
        int input;
        int htm = 0;
        int pth = 0;
        int jumlahhtm = 0;
        int jumlahpth = 0;
        int total = 0;
        int htmterjual = 0, pthterjual = 0;

        do {
            System.out.println("1.stock barang");
            System.out.println("2.pemesanan");
            System.out.println("3.pembayaran");
            System.out.println("4.laporan");
            System.out.println("5.keluar");
            System.out.print("masukan pilihan > ");
            pilihan = new Scanner(System.in).nextInt();
            System.out.println("");
            if (pilihan == 1) {
                do {
                    System.out.println("1.tambah stok warna hitam");
                    System.out.println("2.tambah stok warna putih");
                    System.out.println("3.cek stock");
                    System.out.println("0.kembali");
                    System.out.print("masukan pilihan >");
                    pilihan = new Scanner(System.in).nextInt();
                    System.out.println("");
                    if (pilihan == 1) {
                        System.out.print("tambah berapa? > ");
                        input = new Scanner(System.in).nextInt();
                        for (int i = htm; i < input + htm; i++) {
                            String kode = "htm" + jumlahhtm;
                            hitam.push(new node(i, kode, null));
                        }
                    }
                    if (pilihan == 2) {
                        System.out.print("tambah berapa? > ");
                        input = new Scanner(System.in).nextInt();
                        for (int i = pth; i < input + pth; i++) {
                            String kode = "pth" + jumlahpth;
                            putih.push(new node(i, kode, null));
                        }
                    }
                    if (pilihan == 3) {
                        System.out.println("jumlah OPPO F4s hitam > " + hitam.jumlah());
                        System.out.println("jumlah OPPO F4s putih > " + putih.jumlah());
                    }
                } while (pilihan != 0);
            }


            if (pilihan == 2) {
                int pesanhtm = htm;
                int pesanpth = pth;
                do {
                    System.out.println("1.pesan");
                    System.out.println("0.kembali");
                    System.out.print("masukan pilihan > ");
                    pilihan = new Scanner(System.in).nextInt();
                    System.out.println("");
                    if (pilihan == 1) {
                        System.out.print("masukan nama pelanggan > ");
                        String nama = new Scanner(System.in).next();
                        System.out.print("warna hp yang dibeli > ");
                        String warna = new Scanner(System.in).next();
                        if (warna.equalsIgnoreCase("hitam")) {
                            if (hitam.head == null) {
                                System.out.println("maaf stock habis");
                            } else {
                                pelanggan.push(new node(htm + jumlahhtm, nama, hitam.spop()));
                                htm--;
                            }
                        } else if (warna.equalsIgnoreCase("putih")) {
                            if (putih.head == null) {
                                System.out.println("maaf stock habis");
                            } else {
                                pelanggan.push(new node(pth + jumlahpth, nama, putih.spop()));
                                pth--;
                            }
                        } else {
                            System.out.println("maaf warna tidak ada");
                        }
                        node v=null;
                        node gga=new node(2,"kk",v);
                    }
                } while (pilihan != 0);
            }
            if (pilihan == 3) {
                do {
                    System.out.println("1.pembayaran");
                    System.out.println("0.kembali");
                    System.out.print("masukan pilihan > ");
                    pilihan = new Scanner(System.in).nextInt();
                    System.out.println("");
                    if (pilihan == 1) {
                        int hitung;
                        node bayar = pelanggan.qpop();
                        if (bayar == null) {
                            System.out.println("belum ada yang pesan");
                            System.out.println("");
                            break;
                        }

                        System.out.println("nama  > " + bayar.nama);
                        System.out.println("beli  > OPPO F4s");
                        System.out.println("kode  > " + bayar.pesanan.nama);
                        if (bayar.pesanan.nama.contains("htm")) {
                            System.out.println("warna > hitam");
                            System.out.println("harga > Rp.1.500.000,-");
                            do {
                                System.out.println("jumlah uang yang dibayar >");
                                hitung = new Scanner(System.in).nextInt();
                                if (hitung < 1500000) {
                                    System.out.println("maaf uang kurang");
                                } else {
                                    System.out.println("kembali > Rp." + (hitung - 1500000) + ",-");
                                }
                            } while (hitung < 1500000);
                            total = total + 1500000;
                            htmterjual++;
                        } else {
                            System.out.println("warna > putih");
                            System.out.println("harga > Rp.2.000.000,-");
                            do {
                                System.out.println("jumlah uang yang dibayar >");
                                hitung = new Scanner(System.in).nextInt();
                                if (hitung < 2000000) {
                                    System.out.println("maaf uang kurang");
                                } else {
                                    System.out.println("kembali > Rp." + (hitung - 2000000) + ",-");
                                }
                            } while (hitung < 2000000);
                            total = total + 2000000;
                            pthterjual++;
                        }


                    }
                } while (pilihan != 0);
            }

            if (pilihan == 4) {
                System.out.println("jumlah OPPO F4s terjual :");
                System.out.println("warna hitam > " + htmterjual);
                System.out.println("warna putih > " + pthterjual);
                System.out.println("jumlah pemasukan > Rp." + total + ",-");
                pilihan = 0;
                System.out.println("");
            }
        } while (pilihan != 5);
    }
}



Output



Itulah contoh yang bisa saya sampaikan, semoga bermanfaat.
Jika ada kritik dan saran, tolong tambahkan komentar dibawah ya. Terima Kasih! 
Lihat contoh lain? Klik Disini
atau yang lebih mudah? Klik disini.



Contoh Aplikasi Insert, Update, Delete Penjualan Smartphone atau HP dengan Java NetBeans IDE Reviewed by The Desfionik on April 12, 2017 Rating: 5
All Rights Reserved by KUMAN MERAH © 2014 - 2015
Powered By Blogger, Designed by Sweetheme

Contact Form

Name

Email *

Message *

Powered by Blogger.