NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

// Superclass Ikan
class Ikan {
// Atribut umum untuk semua jenis ikan
protected String nama;
protected String warna;
protected int umur;

// Constructor untuk inisialisasi objek Ikan
public Ikan(String nama, String warna, int umur) {
this.nama = nama;
this.warna = warna;
this.umur = umur;
}

// Method umum untuk semua ikan
public void berenang() {
System.out.println(nama + " sedang berenang.");
}

// Method untuk menampilkan informasi umum
public void tampilkanInfo() {
System.out.println("Nama: " + nama);
System.out.println("Warna: " + warna);
System.out.println("Umur: " + umur + " tahun");
}
}

// Subclass Koi yang mewarisi dari Ikan
class Koi extends Ikan {
// Atribut tambahan khusus untuk Koi
private String jenisKoi;

// Constructor untuk inisialisasi objek Koi
public Koi(String nama, String warna, int umur, String jenisKoi) {
super(nama, warna, umur); // Panggil constructor superclass
this.jenisKoi = jenisKoi;
}

// Override method tampilkanInfo untuk menampilkan informasi Koi
@Override
public void tampilkanInfo() {
super.tampilkanInfo(); // Tampilkan info dari superclass
System.out.println("Jenis Koi: " + jenisKoi);
}
}

// Subclass Arwana yang mewarisi dari Ikan
class Arwana extends Ikan {
// Atribut tambahan khusus untuk Arwana
private String ukuran;

// Constructor untuk inisialisasi objek Arwana
public Arwana(String nama, String warna, int umur, String ukuran) {
super(nama, warna, umur); // Panggil constructor superclass
this.ukuran = ukuran;
}

// Override method tampilkanInfo untuk menampilkan informasi Arwana
@Override
public void tampilkanInfo() {
super.tampilkanInfo(); // Tampilkan info dari superclass
System.out.println("Ukuran: " + ukuran);
}
}

// Subclass Mas Koki yang mewarisi dari Ikan
class MasKoki extends Ikan {
// Atribut tambahan khusus untuk Mas Koki
private String bentukEkor;

// Constructor untuk inisialisasi objek Mas Koki
public MasKoki(String nama, String warna, int umur, String bentukEkor) {
super(nama, warna, umur); // Panggil constructor superclass
this.bentukEkor = bentukEkor;
}

// Override method tampilkanInfo untuk menampilkan informasi Mas Koki
@Override
public void tampilkanInfo() {
super.tampilkanInfo(); // Tampilkan info dari superclass
System.out.println("Bentuk Ekor: " + bentukEkor);
}
}

// Kelas utama untuk menjalankan program
public class Main {
public static void main(String[] args) {
// Membuat objek Koi
Koi koi = new Koi("Koi Jepang", "Merah", 2, "Koi Hias");

// Membuat objek Arwana
Arwana arwana = new Arwana("Arwana Super Red", "Merah", 5, "50 cm");

// Membuat objek Mas Koki
MasKoki masKoki = new MasKoki("Mas Koki Oranda", "Emas", 1, "Ekor Kipas");

// Menampilkan informasi setiap objek
System.out.println("Informasi Koi:");
koi.tampilkanInfo();
koi.berenang();

System.out.println("nInformasi Arwana:");
arwana.tampilkanInfo();
arwana.berenang();

System.out.println("nInformasi Mas Koki:");
masKoki.tampilkanInfo();
masKoki.berenang();
}
}
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.