Here is the code for a class named Kent. You will use this class in creating a c
ID: 3585330 • Letter: H
Question
Here is the code for a class named Kent. You will use this class in creating a class as described below. public class Kent { private int factor; public int getFactor() { return factor; } public void setFactor(int factor) { this.factor = factor; } } Create a class named Essex with the following characteristics: The class has in instance variable, ascent, of integer type. The class has an instance variable, base, that is an object of class Kent. The class has a constructor with two parameters: an int and a Kent object, in that order. The constructor initializes the two instance variables using the parameter values. There is a method with the header public int getApex() that returns the sum of the ascent and the factor of base.
Explanation / Answer
public class Kent {
private int factor;
public int getFactor() {
return factor;
}
public void setFactor(int factor) {
this.factor = factor;
}
}
class Essex {
private int ascent;
private Kent base;
public Essex(int ascent, Kent base) {
this.ascent = ascent;
this.base = base;
}
public int getApex() {
return ascent + base.getFactor();
}
}