cześć,
jak w temacie. Chciałbym ( o ile to możliwe ) utworzyć w konstruktorze klasy White obiekt klasy Dead.
Dostaje komunikat:
" /MyClass.java:27: error: constructor Dead in class Dead cannot be applied to given types;
died = new Dead(this);
^ "
Przy okazji jakby go zainicjować w mainie, już tego nie mam pojęcia jak zrobić :X
Swoją drogą chciałbym zainicjować konstruktor w klasie Dead to dostaje komunikat :
"
/MyClass.java:27: error: incompatible types: White cannot be converted to String
died = new Dead(this);
^
/MyClass.java:44: error: cannot find symbol
this.lifeless=lifeless; }
"
import java.util.*;
import java.io.*;
interface Person{
public void color(String s);
}
class Black implements Person
{
@Override
public void color(String s)
{ System.out.println(" ( Black() Person ) ");
System.out.println(s);
}
}
class White {
Person died;
String grave=null;
public White(String grave){
died = new Dead(this); // ? :X
this.grave=grave;
}
}
class Dead implements Person {
// String lifeless=null;
@Override
public void color(String s)
{ System.out.println("( Dead() Person )");
System.out.println(s);
}
// public Dead(String lifeless){ // :X ?
// this.lifeless=lifeless; } // :X ?
}
public class MyClass {
public static void main(String args[]) {
Black b = new Black();
// b.color("black");
}
}