при переопределении метода clone() в классе С не могу получить доступ к полям класса А т.к в конструкторе не видны методы getI,getJ,getName
package com.javarush.task.task21.task2109;
/*
Запретить клонирование
*/
public class Solution {
public static class A implements Cloneable {
private int i;
private int j;
public A(int i, int j) {
this.i = i;
this.j = j;
}
public int getI() {
return i;
}
public int getJ() {
return j;
}
@Override
public A clone() throws CloneNotSupportedException {
return (A)super.clone();
}
}
public static class B extends A {
private String name;
public B(int i, int j, String name) {
super(i, j);
this.name = name;
}
public String getName() {
return name;
}
@Override
public B clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException();
}
}
public static class C extends B {
public C(int i, int j, String name) {
super(i, j, name);
}
}
@Override
protected Object clone() throws CloneNotSupportedException {
return new C(getI(),getJ().getName());
}
public static void main(String[] args) {
}
}