1 / 6

06 Tugas Praktikum Polymorphism

06 Tugas Praktikum Polymorphism. OOP Java. Pabrik. No. 1. #nama_produk : String #harga : int. +tentukan_harga_jual() : int +toString() : String. Distributor. #wilayah_pemasaran : String #jumlah_salesman : int. +tentukan_harga_jual() : int +toString() : String. Toko. Supermarket.

taima
Télécharger la présentation

06 Tugas Praktikum Polymorphism

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 06 Tugas Praktikum Polymorphism OOP Java

  2. Pabrik No. 1 #nama_produk : String #harga : int +tentukan_harga_jual() : int +toString() : String Distributor #wilayah_pemasaran : String #jumlah_salesman : int +tentukan_harga_jual() : int +toString() : String Toko Supermarket #alamat : String #alamat : String +tentukan_harga_jual() : int +toString() : String +tentukan_harga_jual() : int +toString() : String

  3. Buatlah kelas-kelas diatas beserta kelas testnya masing-masing, kemudian buat kelas TestProduk yg didalamnya melakukan pembentukan & pengaksesan objek sesuai prinsip polymorphism.

  4. Pada TestProduk harus terdapat :Pabrik pd = new Distributor();Pabrik pt = new Toko();Pabrik ps = new Supermarket();Distributor dt = new Toko();Distributor ds = new Supermarket(); Atribut harga pada kelas Pabrik diisi pada default constructor = 10000, sehingga menjadi harga default untuk semua Kelas. Method tentukan_harga_jual() akan mengambil data dari atribut harga, kemudian menghasilkan harga jualnya sbb: Pabrik : harga jual = 100% * hargaDistributor : harga jual = 200% * hargaSupermarket : harga jual = 300% * harga Toko : harga jual = 400% * harga Method toString akan mengembalikan sebuah String yg berisi gabungan data dari semua atribut

  5. Profit No. 2 +hitung_profit(Pabrik p) : double Tambahkan kelas Profit seperti diatas. Method hitung_profit() digunakan untuk menghitung profit sbb :Pabrik : profit = 40% * harga jualDistributor : profit = 30% * harga jualToko : profit = 20% * harga jualSupermarket : profit = 10% * harga jualKemudian buat kelas TestProduk2 yang digunakan untuk menghitung profit objek-objek dari kelas-kelas yang berbeda .

  6. Buat kelas TestProduk3 yang melakukan seperti pada TestProduk dan TestProduk2 tetapi pembentukan semua objeknya digabung jadi satu array dengan menggunakan heterogeneous array, contoh : Pabrik[] p = new Pabrik[10]; p[0] = new Pabrik(); p[1] = new Distributor(); dst No. 3

More Related