Modified:

class A { }
class B extends A { }
class C extends A { }
class D extends B { }
class E extends C { }
class F extends E { }
class G extends D { }
class H extends E { }
| A | C |
| public class A { private String S; private int I; public A (String theS, int
theI) public void ap () |
public class C { private String S; private int I; public C (String theS, int
theI) public void cp () |
| public class A { private String S; private int I; public A (String theS, int
theI) public void ap () |
public class C extends A { public C (String theS, int theI) |
4. (8) Rewrite the following classes to use inheritance and remove duplication. Each class should still perform the same.
| A | B | C |
| public class A { private String S; private int I; private double D; public A (String theS, int theI, double theD) public void ap () |
public class B { private String S; private double D; public B (String theS, double theD) { S = theS; D = theD; } public void bp () |
public class C { private String S; private int I; public C (String theS, int theI)
|
| public class One { private String S; public One (String theS) public void onep () |
public class B extends One { private double D; public B (String theS, double theD) { super(theS); D = theD; } public void bp ()
|
public class C extends One { private int I; public C (String theS, int theI) { super(theS); I = theI; } public void cp ()
|
| public class A extends B { private int I; public A (String theS, int theI, double theD) { super(theS, theD); I = theI; } public void ap () |