Question: Experiment 1: Now type the following code into the main method of Example You may have to comment out statements as you test to see


Experiment 1: Now type the following code into the main method of Example You may have to comment out" statements as you test to see which are valid and which are not Shape 3: Rectangle r = new Rectangle ( 10, 20); Circle - new Circle( 5, "Red" ); I-ci S-C; // Statement #1 // Statement 2 // Statement #3 Experiment 1 x Compile Undo Cut Copy Paste Find... Close Source Code /** * Class Experiment_1 */ import java.util.*; public class Experiment_1 t'i public static void main(String[] args) { ) public class Circle private doubler; private String color; public Circle(String c) color=c; r-0; } public Circle(double rl, String e) {color=Cr-r1;} public void setRadius( double rl) {r=rl; } public double getRadius retum r; } public void setColor( String c) {color=c; } public String getColor() {retum color; } public double getArea { return Math.PI*r*r; } public class Rectangle { private double ; private double w; private String color: public Rectangle {1-0; w=0; color="Blue":} public Rectangle(double 1, double w) {this.1 = 1; this.w-w;color="Blue":) public void setWidth( double w) {this.w=w; public void setLength( double II) { this.I = 1; public double getWidth() {retum :) public double getLength() { return 1; ) public void setColor( String c) {color-c;) public String getColor() { return color; } public double getAreal {return lew.) public String toStringo { return String.format("%s Rectangle size"%.2f by % 21)", color, I, w); } public String toString { return String.format("%s Circle: r-%2f", color, r); }; public class Square private double w; private String color; public Square(String c) { colorec; w0; ) public Square(double w, String c) { setColor(c); setWidth(w); public void setWidth( double wl) { this.w-w;) public double getWidth() {return w;) public void setColor(String e) {color-c} public String getColor { return color, ) public double getArea) { return ww: ) public String toString return String.format("%s Square size-(%.2f by 21)" color, w, w), )
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
