I have no idea how to pass the last requirement. Could anybody give me some help. Appreciate it.
package com.codegym.task.task21.task2109;
import java.util.Objects;
/*
Prevent cloning
*/
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;
}
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;
}
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);
}
}
public static void main(String[] args) {
}
public C clone() throws CloneNotSupportedException{
A a=(A)(super.clone());
int i=a.getI();
int j=a.getJ();
String n=B.getName();
return new C(i,j,n);
}
}