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

public class Rectangle extends GraphObj{ float height; float width; public Recta

ID: 3667799 • Letter: P

Question

public class Rectangle extends GraphObj{
float height;
float width;
  
public Rectangle(float w, float h){
System.out.println("Rectangle::Rectangle()");
height = h;
width = w;

}
  
public void setLength(float R){
if(R < 0)
return;
height = R;
width = R;
}
@Override
public void draw(){
System.out.println("Drawing a Rectangle of color "+color+
" and height " + height+ "and width" + width+ " at "+x+", "+y);
  
  
}

}

i'm not sure if its the right codes can anyone help me

------------------------------------------------------------------------------

please some help

i'm using interfaces codes:

1.include rectangle class which has a width and height .
2. Add a method named "zoom()" that allows all types of objects to be magnified or shrunk. Determine the appropriate parameter(s) and attribute(s), if any, that need to be added to the classes in the project to allow both magnification and shrinking to take place .
3. Your main should create 20 objects chosen at random from circle, square, and rectangle; make them all "draw" (print) themselves; shrink them to half the size; and print them again .
.

Explanation / Answer

//Interface

//Shape.java

public interface Shape {

   void draw();

   void zoom(int factor);

   void shrink(int factor);
}

=====================================

//Rectangle.java

public class Rectangle implements Shape {

   private float width;
   private float height;

   @Override
   public void draw() {
       System.out.println("Drawing Rectangle wwith width : " + width
               + " height : " + height);
   }

   @Override
   public void zoom(int factor) {
       // short form of width = width*factor
       width *= factor;
       height *= factor;
   }

   @Override
   public void shrink(int factor) {
       width /= factor;
       height /= factor;
   }

}

===============================

//Circle.java

public class Circle implements Shape {

   private float radius;

   @Override
   public void draw() {
       System.out.println("Drawing circle with radius : " + radius);
   }

   @Override
   public void zoom(int factor) {
       radius *= factor;
   }

   @Override
   public void shrink(int factor) {
       radius /= factor;
   }

}

=====================================================

//Square.java

public class Square implements Shape {

   private float side;

   @Override
   public void draw() {
       System.out.println("Drawing Square with side : " + side);
   }

   @Override
   public void zoom(int factor) {
       side *= factor;
   }

   @Override
   public void shrink(int factor) {
       side /= factor;
   }

}

=======================================