ZDIRY-TUFWT-EBONM-EYJ00-IDBLANTER.COM
ZDIRY-TUFWT-EBONM-EYJ00
BLANTERWISDOM105

Contoh Program Jasa Pengiriman Paket Internasional Menggunakan OOP di Eclipse

Jumat, 03 Mei 2019
19ADM - Selamat datang kembali lagi bersama saya, kali ini saya kan membahas mengenai program jasa pengiriman paket internasional, yang dimana ini adalah salah satu tugas besar saya di kampus. oke bagi anda yang penasaran boleh silakan di coba dan di kembangkan sesuka hati.

Disini saya membuat 2 Package yaitu package object dan package driver

Berikut ini contoh Syntax Package Driver.
  • Main.java

 package driver;  
 import java.io.BufferedReader;  
 import java.io.IOException;  
 import java.io.InputStreamReader;  
 import java.util.ArrayList;  
 import java.util.Random;  
 import java.util.Scanner;  
 import object.Barang;  
 import object.Satu;  
 import object.Tarif;  
 public class Main extends Satu {  
      public Main(int angka) {  
           super(angka);  
      }  
      static Scanner ssc1 = new Scanner(System.in);  
      static BufferedReader ssc2 = new BufferedReader(new InputStreamReader(System.in));  
      static Tarif trf = new Tarif(0,0,0,0);  
      static Barang brg;  
      static Random nores = new Random();  
      static ArrayList<Barang> data = new ArrayList<Barang>();  
      public static void main(String[] args) throws IOException {  
           do {  
                menu();  
           } while (true);  
      }       
      private static void menu() throws IOException {  
           System.out.println("===============================================");  
           System.out.println("         Welcome To          ");  
           System.out.println("     Fast Express International      ");  
           System.out.println("===============================================");  
           System.out.println("Select Menu :");  
           System.out.println(" 1. Check Price Packet \n 2. Input Packet Data \n 3. Data Packet \n 4. Exit \n 5. Start Menu");  
           System.out.println("===============================================");  
           System.out.print("Choose : ");  
           int pilih = ssc1.nextInt();  
           System.out.println("===============================================");  
           switch (pilih) {  
           case 1:  
                System.out.println();  
                System.out.println("===============================================");  
                System.out.println("Check Tarif Paket");  
                System.out.println("===============================================");  
                System.out.print("Weight Packet (Kg)\t= ");  
                int berat = ssc1.nextInt();  
                System.out.print("Long Packet (Cm)\t= ");  
                int panjang = ssc1.nextInt();  
                System.out.print("Wide Packet (Cm)\t= ");  
                int lebar = ssc1.nextInt();  
                System.out.print("Height Packet (Cm)\t= ");  
                int tinggi = ssc1.nextInt();  
                trf = new Tarif(berat, panjang, lebar, tinggi);  
                trf.rumus();  
                System.out.println("===============================================");  
                System.out.println("Price Is = $. "+trf.tarif);  
                System.out.println("===============================================");  
                System.out.println();  
                berat = 0;  
                panjang = 0;  
                lebar = 0;  
                tinggi = 0;  
                break;  
           case 2:  
                System.out.println();  
                System.out.println("===============================================");  
                System.out.println("Send Packet");  
                System.out.println("===============================================");  
                System.out.print("Name Sender\t\t= ");  
                String namPengirim = ssc2.readLine();  
                System.out.print("Address Sender\t\t= ");  
                String alaPengirim = ssc2.readLine();  
                System.out.print("Name Receiver\t\t= ");  
                String namPenerima = ssc2.readLine();  
                System.out.print("Address Receiver\t= ");  
                String alaPenerima = ssc2.readLine();  
                System.out.print("Weight Packet (Kg)\t= ");  
                berat = ssc1.nextInt();  
                System.out.print("Long Packet (Cm)\t= ");  
                panjang = ssc1.nextInt();  
                System.out.print("Wide Packet (Cm)\t= ");  
                lebar = ssc1.nextInt();  
                System.out.print("Height Packet (Cm)\t= ");  
                tinggi = ssc1.nextInt();  
                int resi = nores.nextInt(999999999) + 111111111;  
                data.add(brg = new Barang(namPengirim, alaPengirim, namPenerima, alaPenerima, resi, berat, panjang, lebar, tinggi));  
                brg.rumus();  
                System.out.println("===============================================");  
                System.out.println("Price To Pay = $. "+brg.tarif);  
                System.out.println("Data Has Been Saved ...");  
                System.out.println("===============================================");  
                System.out.println();  
                break;  
           case 3:  
                System.out.println();  
                System.out.println("===============================================");  
                System.out.println("Data Packet");  
                System.out.println("===============================================");  
                int i = 0;  
                for (Barang o:data) {  
                     System.out.println("Data To - "+(i+1));  
                     System.out.println("Name Sender\t= " + o.getNama_pengirim());  
                     System.out.println("Address Sender\t= " + o.getAlamat_pengirim());  
                     System.out.println("Name Receiver\t= " + o.getNama_penerima());  
                     System.out.println("Address Receiver= " + o.getAlamat_penerima());  
                     System.out.println("Number Tracker\t= " + o.getNomor_resi());  
                     System.out.println("Status\t\t= " + o.getStatus());  
                     System.out.println("Price\t\t= &. " + o.tarif);  
                     System.out.println("===============================================");  
                     i++;  
                }  
                System.out.println();  
                break;  
           case 4:  
                System.out.println("Exit ...");  
                System.exit(0);  
                break;  
           case 5:  
                System.out.println();  
                break;  
           default:  
                System.out.println("Error, Please Fill in the data Correctly ...");  
                break;  
           }  
   }  
      }  


Package Driver.


  • Barang.java
 package object;  
 public class Barang {  
      public String nama_pengirim, alamat_pengirim, nama_penerima, alamat_penerima,  
      status;  
      public int nomor_resi, berat_barang, panjang_barang, lebar_barang, tinggi_barang;  
      public double tarif;  
      public Barang(String nPengirim, String alaPengirim, String nPenerima, String alaPenerima,  
                int resi, int berat, int panjang, int lebar, int tinggi){  
           nama_pengirim = nPengirim;  
           alamat_pengirim = alaPengirim;  
           nama_penerima = nPenerima;  
           alamat_penerima = alaPenerima;  
           berat_barang = berat;  
           panjang_barang = panjang;  
           lebar_barang = lebar;  
           tinggi_barang = tinggi;  
           nomor_resi = resi;  
      }  
      public String getNama_pengirim() {  
           return nama_pengirim;  
      }  
      public String getAlamat_pengirim() {  
           return alamat_pengirim;  
      }  
      public String getNama_penerima() {  
           return nama_penerima;  
      }  
      public String getAlamat_penerima() {  
           return alamat_penerima;  
      }  
      public String getStatus() {  
           status = "Dikirim";  
           return status;  
      }  
      public int getNomor_resi() {  
           return nomor_resi;  
      }  
      public void rumus(){  
           tarif = (berat_barang * 5) + (panjang_barang * lebar_barang * tinggi_barang * 1);  
      }  
 }  
  • Induk.java
 package object;  
 public class Induk {  
      public int berat_barang, panjang_barang, lebar_barang, tinggi_barang;  
      public double tarif;  
      public Induk(int berat, int panjang, int lebar, int tinggi){  
           berat_barang = berat;  
           panjang_barang = panjang;  
           lebar_barang = lebar;  
           tinggi_barang = tinggi;  
      }  
 }  


  • Tarif.java
 package object;  
 public class Tarif extends Induk {  
      public Tarif(int berat, int panjang, int lebar, int tinggi) {  
           super(berat, panjang, lebar, tinggi);  
      }  
      public void rumus(){  
           tarif = (super.berat_barang * 50) + (super.panjang_barang * super.lebar_barang * super.tinggi_barang * 10);  
      }  
 }  

  • Satu.java
 package object;  
 public class Satu {  
      public int angka;  
      public Satu(int angka){  
           this.angka = angka;  
      }  
 }  


Tampilan Jika Program Di Jalankan.

===============================================
                 Welcome To                    
          Fast Express International           
===============================================
Select Menu :
 1. Check Price Packet 
 2. Input Packet Data 
 3. Data Packet 
 4. Exit 
 5. Start Menu
===============================================
Choose : 1
===============================================

===============================================
Check Tarif Paket
===============================================
Weight Packet (Kg) = 50
Long Packet (Cm) = 4
Wide Packet (Cm) = 5
Height Packet (Cm) = 6
===============================================
Price Is = $. 3700.0
===============================================

===============================================
                 Welcome To                    
          Fast Express International           
===============================================
Select Menu :
 1. Check Price Packet 
 2. Input Packet Data 
 3. Data Packet 
 4. Exit 
 5. Start Menu
===============================================
Choose : 2
===============================================

===============================================
Send Packet
===============================================
Name Sender = AriefDM
Address Sender = Indonesia
Name Receiver = Anisa
Address Receiver = Singapur
Weight Packet (Kg) = 23
Long Packet (Cm) = 12
Wide Packet (Cm) = 13
Height Packet (Cm) = 12
===============================================
Price To Pay = $. 1987.0
Data Has Been Saved ...
===============================================

===============================================
                 Welcome To                    
          Fast Express International           
===============================================
Select Menu :
 1. Check Price Packet 
 2. Input Packet Data 
 3. Data Packet 
 4. Exit 
 5. Start Menu
===============================================
Choose : 3
===============================================

===============================================
Data Packet
===============================================
Data To - 1
Name Sender = AriefDM
Address Sender = Indonesia
Name Receiver = Anisa
Address Receiver= Singapur
Number Tracker = 751590493
Status = Dikirim
Price = &. 1987.0
===============================================

===============================================
                 Welcome To                    
          Fast Express International           
===============================================
Select Menu :
 1. Check Price Packet 
 2. Input Packet Data 
 3. Data Packet 
 4. Exit 
 5. Start Menu
===============================================
Choose : 5
===============================================

===============================================
                 Welcome To                    
          Fast Express International           
===============================================
Select Menu :
 1. Check Price Packet 
 2. Input Packet Data 
 3. Data Packet 
 4. Exit 
 5. Start Menu
===============================================
Choose : 4
===============================================

Exit ...



Sekian artikel dari saya, semoga bermanfaat bagi anda semuanya. jangan lupa jika ingin memberi kritik saran bisa ke komentar.
Share This :
AriefDM

Perkenalkan nama saya AriefDM selaku penulis dan pemilik di web ini. Instagram : @ariefdm19

1 komentar

Silakan Berikan Komentar Anda
- Komentar dengan sopan
- Dilarang spam Komentar
- Dilarang memberikan link aktif pada kolom komentar
- Dilarang menggunakan Kosa Kata yang Kasar atau Negatif

Salam Hangat
AriefDM

  1. Silakan Berikan Komentar Anda
    - Komentar dengan sopan
    - Dilarang spam Komentar
    - Dilarang memberikan link aktif pada kolom komentar
    - Dilarang menggunakan Kosa Kata yang Kasar atau Negatif

    Salam Hangat

    BalasHapus