public class RectangleDemo {
private class Rectangle {
private double height;
private double width;
private String color;
public Rectangle(double wid, double high){
height = high;
width = wid;
}
public Rectangle(){
height = 1;
width = 1;
color = "White";
}
public void setHeight(double high){
height = high;
}
public void setWidth(double wid){
width = wid;
}
public void setColor(String col){
color = col;
}
public double getArea(){
return height*width;
}
public double getPerimeter(){
return 2*(height + width);
}
public void getColor(){
System.out.println("Color is: " + color +" ");
return;
}
}
Solution
public class RectangleDemo {
private class Rectangle {
private double height;
private double width;
private String color;
public Rectangle(double wid, double high){
height = high;
width = wid;
}
public Rectangle(){
height = 1;
width = 1;
color = "White";
}
public void setHeight(double high){
height = high;
}
public void setWidth(double wid){
width = wid;
}
public void setColor(String col){
color = col;
}
public double getArea(){
return height*width;
}
public double getPerimeter(){
return 2*(height + width);
}
public void getColor(){
System.out.println("Color is: " + color +" ");
return;
}
}

    public class RectangleDemo {     private class Rectangle {  .pdf

  • 1.
    public class RectangleDemo{ private class Rectangle { private double height; private double width; private String color; public Rectangle(double wid, double high){ height = high; width = wid; } public Rectangle(){ height = 1; width = 1; color = "White"; } public void setHeight(double high){ height = high; } public void setWidth(double wid){ width = wid; } public void setColor(String col){ color = col; } public double getArea(){ return height*width; } public double getPerimeter(){ return 2*(height + width); } public void getColor(){ System.out.println("Color is: " + color +" "); return; } }
  • 2.
    Solution public class RectangleDemo{ private class Rectangle { private double height; private double width; private String color; public Rectangle(double wid, double high){ height = high; width = wid; } public Rectangle(){ height = 1; width = 1; color = "White"; } public void setHeight(double high){ height = high; } public void setWidth(double wid){ width = wid; } public void setColor(String col){ color = col; } public double getArea(){ return height*width; } public double getPerimeter(){ return 2*(height + width); } public void getColor(){ System.out.println("Color is: " + color +" "); return; } }