Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

need it with comments, please. thanks In this lab you will create two classes, o

ID: 3560972 • Letter: N

Question

need it with comments, please. thanks

In this lab you will create two classes, one a superclass of the other. You will observer how methods are inherited and used through the subclass.

Requirements

The archive LengthScaledLengthLab-part1-140725.zip (please, see below)has the source code for a project. Your job is to complete the classes Length and ScaledLength so that the tests work.

The class Length should have two instance fields, named value and unit. value is a decimal number while unit is a string.

The class ScaledLength extends Length. ScaledLength has one instance variable named scale. scale is a decimal number.

Both classes should have getters and setters for all the instance variables.

The Length class should have a method named combined which returns the value concatenated with the unit. The method takes no parameters and returns a String.

Test programs are in the test folder.

Source code for a project

package cs2302.measures;

public class Length {

}

package cs2302.measures;

public class ScaledLength {

}

Explanation / Answer

package cs2302.measures;

// Length class
public class Length
{
// two instance fields, named value and unit. value is a decimal number while unit is a string.
privateString unit;
private float value;

// getters and setters for all the instance variables
public String getUnit() {
return unit;
}

public void setUnit(String unit) {
this.unit = unit;
}

public float getValue() {
return value;
}

public void setValue(float value) {
this.value = value;
}
  
// method named combined which returns the value concatenated with the unit.
//The method takes no parameters and returns a String.
  
public String combined()
{
return "Value : "+value+" "+"Unit : "+unit;
}

}

package cs2302.measures;

// ScaledLength class
public class ScaledLength extends Length
{
// one instance variable named scale. scale is a decimal number
float scale;

// getters and setters for scale
public float getScale() {
return scale;
}

public void setScale(float scale) {
this.scale = scale;
}
  
}