6.1
class Rectangle
{
private double width;
private double height;
static String color;
public Rectangle()
{
double width=1;
double height=1;
}
public Rectangle(double width,double height,String color)
{
this.width=width;
this.height=height;
this.color=color;
}
public double getWidth()
{
return width;
}
public void setWith(double width)
{
this.width=width;
}
public double getHeight()
{
return height;
}
public void setHeight(double height)
{
this.height=height;
}
public static String getColor()
{
return color;
}
public static void setColor(String newcolor)
{
color=newcolor;
}
public double findArea()
{
return width*height;
}
public double findPerimeter()
{
return 2*(width+height);
}
}
public class Test61
{
public static void main(String[] args)
{
Rectangle rect1=new Rectangle(4,40,"yellow");
Rectangle rect2=new Rectangle(4,40,"yellow");
System.out.println("Rectangle 1:\n"+"width: "+rect1.getWidth()+",height: "+rect1.getHeight()+",color: "+rect1.getColor()+",perimeter: "+rect1.findPerimeter()+",area: "+rect1.findArea());
System.out.println("Rectangle 2:\n"+"width: "+rect2.getWidth()+",height: "+rect2.getHeight()+",color: "+rect2.getColor()+",perimeter: "+rect2.findPerimeter()+",area: "+rect2.findArea());
}
}
class Rectangle
{
private double width;
private double height;
static String color;
public Rectangle()
{
double width=1;
double height=1;
}
public Rectangle(double width,double height,String color)
{
this.width=width;
this.height=height;
this.color=color;
}
public double getWidth()
{
return width;
}
public void setWith(double width)
{
this.width=width;
}
public double getHeight()
{
return height;
}
public void setHeight(double height)
{
this.height=height;
}
public static String getColor()
{
return color;
}
public static void setColor(String newcolor)
{
color=newcolor;
}
public double findArea()
{
return width*height;
}
public double findPerimeter()
{
return 2*(width+height);
}
}
public class Test61
{
public static void main(String[] args)
{
Rectangle rect1=new Rectangle(4,40,"yellow");
Rectangle rect2=new Rectangle(4,40,"yellow");
System.out.println("Rectangle 1:\n"+"width: "+rect1.getWidth()+",height: "+rect1.getHeight()+",color: "+rect1.getColor()+",perimeter: "+rect1.findPerimeter()+",area: "+rect1.findArea());
System.out.println("Rectangle 2:\n"+"width: "+rect2.getWidth()+",height: "+rect2.getHeight()+",color: "+rect2.getColor()+",perimeter: "+rect2.findPerimeter()+",area: "+rect2.findArea());
}
}