Write a class called BlanketLadder that describes a blanket ladder by its height, width, number of rungs and colour. Write setters and getters for all instance data. Write a method that returns the space between rungs, assuming there is no rung at the bottom of the blanket ladder, a rung at the top, and that the rungs are equispaced. If the height of the blanket ladder is 21cm and there are 3 rungs, they should be 7cm apart. This method should return a double and you should print only 2 decimal spaces for each returned value (e.g., a 200cm blanket ladder with 3 rungs would have 66.67cm between rungs, not 66.666666666). When a blanket ladder is printed, it should be described as in the sample output below.
Write a class called Assignment4Smajli162513 that creates two blanket ladders. Give them any dimensions, number of rungs and colours you'd like. Print both blanket ladders. Then print the distance between the rungs for both blanket ladders, referencing the colour of each blanket ladder using a getter (they should have different colours). Change one of the blanket ladder's colour to pink and the other's width to 68. Print both blanket ladders.
the image attached is what it should look like
Blanketladder
import java.text.DecimalFormat;
public class BlanketLadder {
private double height;
private double width;
private int numRungs;
private String color;
public BlanketLadder(double height, double width, int numRungs, String color) {
this.height = height;
this.width = width;
this.numRungs = numRungs;
this.color = color;
}
public double getHeight() {
return height;
}
public void setHeight(double height) {
this.height = height;
}
public double getWidth() {
return width;
}
public void setWidth(double width) {
this.width = width;
}
public int getNumRungs() {
return numRungs;
}
public void setNumRungs(int numRungs) {
this.numRungs = numRungs;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public double spaceBetweenRungs() {
double space = (height - 1) / (numRungs - 1);
DecimalFormat df = new DecimalFormat("#.##");
return Double.parseDouble(df.format(space));
}
@Override
public String toString() {
return "Blanket Ladder: Height = " + height + "cm, Width = " + width + "cm, Rungs = " + numRungs + ", Color = " + color;
}
}
public class Assignment3Smajli162513 {
public static void main(String[] args) {
BlanketLadder blanketLadder1 = new BlanketLadder(21, 60, 3, "Blue");
BlanketLadder blanketLadder2 = new BlanketLadder(100, 50, 4, "Green");
System.out.println(blanketLadder1);
System.out.println(blanketLadder2);
System.out.println("The space between rungs for the " + blanketLadder1.getColor() + " blanket ladder is " + blanketLadder1.spaceBetweenRungs() + "cm");
System.out.println("The space between rungs for the " + blanketLadder2.getColor() + " blanket ladder is " + blanketLadder2.spaceBetweenRungs() + "cm");
blanketLadder1.setColor("Pink");
blanketLadder2.setWidth(68);
System.out.println(blanketLadder1);
System.out.println(blanketLadder2);
}