Butuh bantuan, soalnya sudah ga' bisa lagi.....!!!

Topik sebelumnya Topik selanjutnya Go down

Mungkin begini

Post  zz on Fri Aug 28, 2009 11:12 pm

Code:

class Divan
{
public int a = 5;
protected int b = 7;

   public void info()
   {
      System.out.println("Dipanggil pada " + this.getClass().getName());
      System.out.println("a = " + a);
      System.out.println("b = " + b);
   }
}
class Jenny extends Divan
{
   private int c = 9;

   public void info()
   {
      System.out.println("Dipanggil pada" + this.getClass().getName());
      System.out.println("a = " + a);
      System.out.println("b = " + b);
      System.out.println("c = " + c);
   }
}
class Master
{
   public static void main(String [] args)
   {
      Divan objX = new Divan();
      objX.info();

      Jenny objY = new Jenny();
      objY.info();
   }
}
class Student extends Divan
{
private int c = 9;

   public void info()
   {
      super.info();
      // Panggil metode kelas dasar
      System.out.println(" c = " + c);
   }
}
class Superkelas
{
public static void main(String [] args)
{
Student obj = new Student();
obj.info();
}
}
class Cewek
{
private String nama;
private int status;

// Konstruktor
public Cewek(String nama, int status)
{
this.nama = nama;
this.status = status;
}
// Metode
public void info()
{
System.out.println("Nama = " + this.nama);
System.out.println("Status = " + this.status);

}
}
// Akhir kelas Cewek
class Cowok extends Cewek
{
protected String sifatCowok;

// konstruktor
public Cowok(String sifatCowok, String nama, int status)
{
super(nama, status);
this.sifatCowok = sifatCowok;
}
// Metode
public void info()
{
System.out.println("Sifat cowok : " + this.sifatCowok);
super.info();
}
}
// Akhir kelas Cowok
public class tarzan
{
   public static void main(String [] args)
   {
      Cowok keren = new Cowok("Baik", "Divan", 1);
      keren.info();
   }
}
error disebabkan parameter kelas cowok adalah (String,String,int ) sedangkan disaat memanggil klass Cowok parameter yang anda masukkan adalah
(String,String,String).
Mungkin begitu...
GoodLuck......

zz
Panglima
Panglima

Jumlah posting : 121
Age : 71
Lokasi : france
Registration date : 13.02.09

Lihat profil user

Kembali Ke Atas Go down

Butuh bantuan, soalnya sudah ga' bisa lagi.....!!!

Post  arip on Fri Aug 28, 2009 7:46 pm

class Divan
{
public int a = 5;
protected int b = 7;

public void info()
{
System.out.println("Dipanggil pada " + this.getClass().getName());
System.out.println("a = " + a);
System.out.println("b = " + b);
}
}
class Jenny extends Divan
{
private int c = 9;

public void info()
{
System.out.println("Dipanggil pada" + this.getClass().getName());
System.out.println("a = " + a);
System.out.println("b = " + b);
System.out.println("c = " + c);
}
}
class Master
{
public static void main(String [] args)
{
Divan objX = new Divan();
objX.info();

Jenny objY = new Jenny();
objY.info();
}
}
class Student extends Divan
{
private int c = 9;

public void info()
{
super.info();
// Panggil metode kelas dasar
System.out.println(" c = " + c);
}
}
class Superkelas
{
public static void main(String [] args)
{
Student obj = new Student();
obj.info();
}
}
class Cewek
{
private String nama;
private int status;

// Konstruktor
public Cewek(String nama, int status)
{
this.nama = nama;
this.status = status;
}
// Metode
public void info()
{
System.out.println("Nama = " + this.nama);
System.out.println("Status = " + this.status);

}
}
// Akhir kelas Cewek
class Cowok extends Cewek
{
protected String sifatCowok;

// konstruktor
public Cowok(String sifatCowok, String nama, int status)
{
super(nama, status);
this.sifatCowok = sifatCowok;
}
// Metode
public void info()
{
System.out.println("Sifat cowok : " + this.sifatCowok);
super.info();
}
}
// Akhir kelas Cowok
public class Tarzan
{
public static void main(String [] args)
{
Cowok keren = new Cowok("Baik", "Divan", "Single");
keren.info();

}
}

arip
Pejuang
Pejuang

Jumlah posting : 36
Registration date : 05.03.09

Lihat profil user

Kembali Ke Atas Go down

Topik sebelumnya Topik selanjutnya Kembali Ke Atas


 
Permissions in this forum:
Anda tidak dapat menjawab topik